Code to print two copies from selected sheet

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Otapi
Posts: 13
Joined: Thu Mar 13, 2008 10:43 am

Code to print two copies from selected sheet

Post by Otapi »

Im using openoffice calc and I've got this code

Code: Select all

oDoc = ThisComponent
Dim Props(0) As New com.sun.star.beans.PropertyValue
Props(0).Name = "CopyCount" : Props(0).Value = 2
Props(0).Name = "Sort" : Props(0).Value = True
ThisComponent.Print(Props())
At the moment it does nothing but prints all sheets that have something written on them, but what it should do is that it should print only selected sheets twice (also know as "make a copy of them"). So if there is any code or anything that you can assist me with i would be very grateful, thanks.

EDIT: I have even checked all the pring range topics but all they do is tell me how can print sheets from X to Z and not how i can print those sheets that i have selected.
User avatar
uros
Volunteer
Posts: 30
Joined: Sun Dec 02, 2007 10:26 pm
Location: Slovenia

Re: Code to print two copies from selected sheet

Post by uros »

Hi Otapi!
Check Tools > Options > OpenOffice.org Calc > Print > Print selected sheets only
Hope it helps!
Uros
Otapi
Posts: 13
Joined: Thu Mar 13, 2008 10:43 am

Re: Code to print two copies from selected sheet

Post by Otapi »

Unfortunately it must not go that way, my employer wants the button to do all the work so that they don't have to touch options or anything at all.
Otapi
Posts: 13
Joined: Thu Mar 13, 2008 10:43 am

Re: Code to print two copies from selected sheet

Post by Otapi »

Hey, i changed the code but it still does not work the way it should...

The new code is

Code: Select all

Dim oPropertyValue(0) as New com.sun.star.beans.PropertyValue
oDoc = ThisComponent
oPropertyValue(0).Name = "Print only selected sheets" : oPropertyValue(0).Value = True
oDoc.Print(oPropertyValue()) 
...But it still prints all sheets that have text on them were they selected or not

So umm, what kind of code or properties i need to make it work?
Post Reply