Hi All,
I have a lot of OOo documents that I want to convert into PDF.
They are all in a directory, and I would like OOo to cycle through all
the .odt files in that directory and then create .pdf files (with the
same root name).
I used to be able to do this, using 1.9.x I think.
There are a number of tutorials out there which show how to do this, and
this is what I had followed previously. e.g., DannyB on oooforum had a
macro that worked, and you can find a similar one in Andrew Pitonyak's
macro document. There's also a really nice gui document created by
Laurent GOdard (http://oooconv.free.fr/batchconv/batchconv_fr.html)
which does exactly what I want.
But... in every case, I get an error, even with the macros that used to
work.
Here is the typical code:
Sub ConvertWordToPDF( cFile )
cURL = ConvertToURL( cFile )
' Open the document.
' Just blindly assume that the document is of a type that OOo will
' correctly recognize and open -- without specifying an import filter.
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0, Array(_
MakePropertyValue( "Hidden", True ),_
) )
cFile = Left( cFile, Len( cFile ) - 4 ) + ".pdf"
cURL = ConvertToURL( cFile )
' Save the document using a filter.
oDoc.storeToURL( cURL, Array(_
MakePropertyValue( "FilterName", "writer_pdf_Export" ),_
)
oDoc.close( True )
End Sub
Function MakePropertyValue( Optional cName As String, Optional uValue ) As
com.sun.star.beans.PropertyValue
Dim oPropertyValue As New com.sun.star.beans.PropertyValue
If Not IsMissing( cName ) Then
oPropertyValue.Name = cName
EndIf
If Not IsMissing( uValue ) Then
oPropertyValue.Value = uValue
EndIf
MakePropertyValue() = oPropertyValue
End Function
This always seems to fail with storeToURL() failing, saying that the URL
is of an unsupported form.
But the URLs for the incoming and outgoing files seem OK: something like
file:///C:/tmp/convOO/UW/file.odt
is an example of the incoming file. The outgoing file would be the same
except suffixed with .pdf instead of .odt
There seems to be something I'm missing here. Can anybody help, or
point out a resource for doing this?
By the Way: All of these macros which I lifted seem to have had their
genesis in OOo 1.1 . Does anybody know if perhaps something has changed
in 2.0.2 that breaks things?
Thanks,
Frank Jones
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]