This code used to work. (I don’t know what changed.) oDoc is a document object. This is supposed to save the document to a .pdf file with the url stored in the string sPdfUrl.
oFileAccess = createUnoService(“com.sun.star.ucb.SimpleFileAccess”)
args2(0).Name = “FilterName”
args2(1).Name = “ConvertOOoTargetToPDFTarget”
args2(1).Value = True
If sFileNameExtension = “odt” then
args2(0).Value = “writer_pdf_Export”
ElseIf sFileNameExtension = “ods” then
args2(0).Value = “calc_pdf_Export”
ElseIf sFileNameExtension = “odm” then
args2(0).Value = “writer_globaldocument_pdf_Export”
End IfIf FileExists(sPdfUrl) Then
oFileAccess.setReadOnly(sPdfUrl, False)
End If
oDoc.storeToURL(sPdfUrl, args2())
That last line just gives me:
BASIC runtime error.
An exception occurred
Type: com.sun.star.io.IOException
Message: SfxBaseModel::impl_store <file:///L:/QMS%20Documents/Controlled/(QP)%20Measurement%20Capability%20Assurance.pdf> failed: 0x20d(Error Area:Io Class:General Code:13).