Version: 7.6.2.1 (X86_64) / LibreOffice Community
Build ID: 60(Build:1)
CPU threads: 4; OS: Linux 6.5; UI render: default; VCL: gtk3
Locale: en-GB (en_GB.UTF-8); UI: en-GB
7.6.2-3
Calc: threaded
If I manually select a range of cells in one sheet from a spreadsheet with multiple sheets, then File | Export as PDF… | Under Range Check the Selection/Selected Sheeet(s) then click Export. The selection is printed to a PDF as a single page from the selection I chose.
However if I record a macro following exactly the same steps, the exported PDF includes all the sheets with many pages.
Here’s the recorded macro with all properties not related to Selection elided from the array generated from the Export To PDF dialog.
sub ExportPDF
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "glycaemia (glycaemia)"
dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())
rem ----------------------------------------------------------------------
dispatcher.executeDispatch(document, ".uno:DefinePrintArea", "", 0, Array())
rem ----------------------------------------------------------------------
dim args3(2) as new com.sun.star.beans.PropertyValue
args3(0).Name = "URL"
args3(0).Value = "file:///home/bhrgunatha/selection.pdf"
args3(1).Name = "FilterName"
args3(1).Value = "calc_pdf_Export"
args3(2).Name = "FilterData"
args3(2).Value = Array(Array("UseLosslessCompression",0,false,com.sun.star.beans.PropertyState.DIRECT_VALUE),Array("Quality",0,90,com.sun.star.beans.PropertyState.DIRECT_VALUE)[elided many properties...,]Array("SelectPdfVersion",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),[...],Array("PDFViewSelection",0,0,com.sun.star.beans.PropertyState.DIRECT_VALUE),[...]Array("Selection",0,,com.sun.star.beans.PropertyState.DIRECT_VALUE)[...])
dispatcher.executeDispatch(document, ".uno:ExportToPDF", "", 0, args3())
end sub
Can I modify the macro so it doesn’t export all sheets as many pages and just the selection as a single page?