Select multiple sheets for printing

Creating a macro - Writing a Script - Using the API

Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 2:58 pm

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
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RoryOF » Thu Nov 02, 2017 3:09 pm

There are some printing macros at
https://forum.openoffice.org/en/forum/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.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25499
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 3:15 pm

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
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RoryOF » Thu Nov 02, 2017 3:23 pm

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.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25499
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 5:44 pm

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
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RoryOF » Thu Nov 02, 2017 5:53 pm

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   Expand viewCollapse view
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.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25499
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 6:40 pm

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
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RoryOF » Thu Nov 02, 2017 6:53 pm

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.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25499
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 6:59 pm

No, can you address me to some documentation about how to use MRI?
OpenOffice 4.1.4 - Windows 10
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RoryOF » Thu Nov 02, 2017 7:17 pm

Apache OpenOffice 4.1.4 on Xubuntu 16.04.03 (mostly 64 bit version) and infrequently on Win2K/XP
14 October 2016 was Pooh's 90th birthday
User avatar
RoryOF
Moderator
 
Posts: 25499
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 7:26 pm

Thank you so much
OpenOffice 4.1.4 - Windows 10
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby RPG » Thu Nov 02, 2017 7:41 pm

Maybe switch off option for printing selected sheet

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

Romke
LibreOffice 5.3.6.1 on openSUSE Leap 42.3
RPG
Volunteer
 
Posts: 2102
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Select multiple sheets for printing

Postby manupik » Thu Nov 02, 2017 7:49 pm

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
manupik
 
Posts: 7
Joined: Thu Nov 02, 2017 2:51 pm

Re: Select multiple sheets for printing

Postby Zizi64 » Thu Nov 02, 2017 7:56 pm

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.
https://forum.openoffice.org/en/forum/v ... hp?t=39987
Tibor Kovacs, Hungary; LO4.4.7, LO5.3.7 on Win7x64Prof.
PortableApps, WinPenPack: LO3.3.0-LO5.4.2 and AOO4.1.3
Please, edit the topic's initial post, and add the word "[Solved]" at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 6067
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 5 guests