i have a macro like this, when i run command line with headless it crashes.
after debugging i found it error after assigning document = ThisComponent.
the code below I have referenced in other questions, but for me it doesn’t work.
Sub FitToPage
On Error Resume Next
Dim document As Object
Dim pageStyles As Object
Dim sheetCount as Integer
document = ThisComponent
pageStyles = document.StyleFamilies.getByName("PageStyles")
sheetCount = document.Sheets.Count - 1
For i = 0 To sheetCount
Dim sheet As Object, style As Object
sheet = document.Sheets(i)
style = pageStyles.getByName(sheet.PageStyle)
style.ScaleToPagesX = 100
Next i
document.storeSelf(Array())
document.close(true)
End Sub