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


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

OpenOffice 4.1.5 on Windows 10
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

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


Dim aPrintingAreas(oDoc.Sheets.getCount-1)

For i=0 to oDoc.Sheets.getCount-1

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


LibreOffice 5.4, Windows 7, 2010
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 5 guests