Get which sheet is being printed

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
mateus_bisognin
Posts: 1
Joined: Mon Nov 19, 2018 7:08 pm

Get which sheet is being printed

Post by mateus_bisognin »

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

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
VBandOoffice
Posts: 33
Joined: Tue Jul 31, 2018 10:11 am

Re: Get which sheet is being printed

Post by VBandOoffice »

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 7.5, Windows 10, VB.net 2019, C#
Post Reply