Get which sheet is being printed

Creating a macro - Writing a Script - Using the API

Get which sheet is being printed

Postby mateus_bisognin » Mon Nov 19, 2018 7:31 pm

Hi,

I am trying to create a macro that backups data from a document to a csv file, but my main objective is to only backup data from the sheet that is being printed.

So, in my understanding, the way to do this is by attaching a macro to the "onprint" event, getting which sheet is being printed, then running some code.

On these 3 steps, I can't figure it out step 2: "get which sheet is being printed". I would like to, as the user goes through printing options on normal interface and sets which sheets and pages he wants to print, then set it to print, I want to grab these selected options as input to a macro.

I tried something like this attached to "onprint" event:
Code: Select all   Expand viewCollapse view
Sub Main(Event As Object)
...
End Sub

But then, I did not go anywhere.

Does anyone know if it is possible?

Hope I made it understantable.

Thank you in advance

Mateus
OpenOffice 4.1.5 on Windows 10
mateus_bisognin
 
Posts: 1
Joined: Mon Nov 19, 2018 7:08 pm

Re: Get which sheet is being printed

Postby VBandOoffice » Thu Nov 29, 2018 3:50 pm

Hi,
all print areas are items of an array. This snippet is not tested...
I hope this will help you.

oDoc=ThisComponent
oSheets=oDoc.Sheets

Dim aPrintingAreas(oDoc.Sheets.getCount-1)

For i=0 to oDoc.Sheets.getCount-1
aPrintingAreas(i)=oSheets(i).getPrintAreas()

' check if empty! Do what you want if not empty

Next

Regards,
VBandOoffice
LibreOffice 5.4, Windows 7, VB.net 2010
VBandOoffice
 
Posts: 27
Joined: Tue Jul 31, 2018 10:11 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 1 guest