Sub SaveAsPDF_demo()
'
' Save an existing writer document as PDF
'
Dim oSM, oDesk, oDoc As Object 'OOo objects
Dim OpenParam(1) As Object 'Parameters to open the doc
Dim SaveParam(1) As Object 'Parameters to save the doc
Set oSM = CreateObject("com.sun.star.ServiceManager")
Set oDesk = oSM.createInstance("com.sun.star.frame.Desktop")
Set OpenParam(0) = MakePropertyValue("Hidden", True) ' Open the file hidden
Set oDoc = oDesk.loadComponentFromURL("file:///C:/tmp/OOPROBA.odt", "_blank", 0, OpenParam())
Set SaveParam(0) = MakePropertyValue("FilterName", "writer_pdf_Export")
Call oDoc.storeToURL("file:///C:/tmp/OOPROBA.pdf", SaveParam())
Set oDesk = Nothing
Set oSM = Nothing
End Sub
|