Select multiple sheets for printing

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Select multiple sheets for printing

Post 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
OpenOffice 4.1.4 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post 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.
OpenOffice 4.1.4 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post 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.
OpenOffice 4.1.4 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post 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
OpenOffice 4.1.4 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Post 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.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post by manupik »

No, can you address me to some documentation about how to use MRI?
OpenOffice 4.1.4 - Windows 10
User avatar
RoryOF
Moderator
Posts: 34610
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Post 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
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post by manupik »

Thank you so much
OpenOffice 4.1.4 - Windows 10
RPG
Volunteer
Posts: 2250
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Select multiple sheets for printing

Post by RPG »

Maybe switch off option for printing selected sheet

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

Romke
LibreOffice 7.1.4.2 on openSUSE Leap 15.2
manupik
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Post 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.
OpenOffice 4.1.4 - Windows 10
User avatar
Zizi64
Volunteer
Posts: 11358
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Select multiple sheets for printing

Post 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
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
Post Reply