Hi all,
following macro runs correctly except that UI with excel file gets opened. Hidden option is not working.
Also tried to add both headless and hidden options on command line, no luck.
Any hint?
Sub ExportToPDF(inputArg as string, outputArg as string)
dim document as object
dim dispatcher as object
inputFile = ConvertToURL(inputArg)
outputFile = ConvertToURL(outputArg)
dim args2(1) as new com.sun.star.beans.PropertyValue
args2(0).Name = "MacroExecutionMode"
args2(0).Value = 4
args2(1).Name = "Hidden"
args2(1).Value = True
component = StarDesktop.loadComponentFromURL(inputFile, "_default",0,args2)
document = component.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
sheets = component.getSheets()
sheet = sheets.getByName("AvionicsDataSource")
sheet.isVisible = False
for each sheet in sheets.ElementNames
sheet = sheets.getByName(sheet)
sheet.AutomaticPrintArea = True
next
styleFamilies = component.StyleFamilies
pageStyles = styleFamilies.getByName("PageStyles")
numStyles = pageStyles.Count
For count = 0 To numStyles - 1
defaultStyle = pageStyles(count)
defaultStyle.ScaleToPagesX = 1
rem defaultStyle.ScaleToPagesY = 1
Next count
dim args1(1) as new com.sun.star.beans.PropertyValue
args1(0).Name = "URL"
args1(0).Value = outputFile
args1(1).Name = "FilterName"
args1(1).Value = "calc_pdf_Export"
dispatcher.executeDispatch(document, ".uno:ExportDirectToPDF", "", 0, args1())
End Sub
This is the command line:
c:\testFolder\LibreOffice>LibreOfficePortable.exe
-headless "macro:///Standard.Module1.ExportToPDF(C:\testFolder\LibreOffice\Report.xlsx,C:\testFolder\LibreOffice\report.pdf)