Page 1 of 1

Select multiple sheets for printing

Posted: Thu Nov 02, 2017 2:58 pm
by manupik
Hi everyone.

I have a spreadsheet containing multiple sheets. I need to print all the sheets together programmatically.

I'm looking for a function that will select all my sheets before launching oDoc.print(prop())
Or a function to uncheck programmatically the option in File>Printer settings...>Options...> "Print only selected sheets"
Or a function to enable the option "All sheets" in the print dialog

Thank you in advance

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 3:09 pm
by RoryOF
There are some printing macros at
viewtopic.php?f=21&t=56713

At least one of these gives details of printing a specific page, so they might be a good place to start.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 3:15 pm
by manupik
Thank you for your reply. I've looked through the documentation provided, but I don't need to print a specific page. I need to print ALL pages.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 3:23 pm
by RoryOF
Pick up the API calls used and follow them in the API documentation; also refer to Andrew Pitonyak's documentation.

You want this macro - you must do some work on it.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 5:44 pm
by manupik
I've spent hours looking for a solution. I've searched in this forum and in many others, but nothing. I haven't come here to hear "Go and read more documentation". If anybody can help me with this I would be grateful.
Thank you anyway for your kind reply.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 5:53 pm
by RoryOF
It is helpful if you tell us initially that you have searched. If you look at the OO Basic manual, you will see that this code is given:

Code: Select all

Dim Doc as Object
Dim PrintProperties() as New com.sun.star.beans.PropertyValue

PrintProperties(0).Name="Pages"
PrintProperties(0).Value="1-3; 7; 9"
Doc.print(PrintProperties())

and it is stated that the syntax of values for PrintProperties(0).Value is that of the OO Print screen. By default OO Print prints all sheets, so I suggest that by not setting values for PrintProperties(0).Value you may default to all sheets.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 6:40 pm
by manupik
Thank you for your reply. Of course I have searched. It's a long time I've been working with OO interoperabilty and I always found what I was looking for, especially in this forum. But in this case I couldn't, that's why I asked.
As for your solution, I already tried with "Pages" property. But it doesn't change the sheets that are going to be printed. To change that property it is the same as changing the option under "Print Content" in the print dialog of OpenOffice Calc. IN order to have ALL your sheets printed you'll also need to select the option "All sheets" under "Range and copies". It is that very option that I'm unable to activate programmatically.
Thanks

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 6:53 pm
by RoryOF
Have you examined your code using MRI? It should show you the options available. There may be an "allsheets" or equivalent property which has not been documented.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 6:59 pm
by manupik
No, can you address me to some documentation about how to use MRI?

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 7:17 pm
by RoryOF
The fullest documentation is at
https://github.com/hanya/MRI/wiki

A tutorial is at
viewtopic.php?f=20&t=90171

and the application itself is at
https://extensions.openoffice.org/en/pr ... ction-tool

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 7:26 pm
by manupik
Thank you so much

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 7:41 pm
by RPG
Maybe switch off option for printing selected sheet

read
Printing from multiple sheets (View topic) • Apache OpenOffice Community Forum

Romke

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 7:49 pm
by manupik
It is exactly that option that I would like to handle, but programmatically. I'm programming within an application in vb.net. The user won't even see the spreadsheet as I'm launching it with the hidden property enabled. So I need to handle it within the code.

Re: Select multiple sheets for printing

Posted: Thu Nov 02, 2017 7:56 pm
by Zizi64
Tip 1:
You can use a loop for activate sheets one by one. Then you can print the active sheets by your code from the loop.
viewtopic.php?t=39987