I am sure there is no space like what you said.
actually I have two problem
the first is if I copy your code or the one in my first post,
I always got a wrong cURL when run to
Sub SaveDocAsPDF( cFile )
Dim oDoc as object
cURL = ConvertToURL( cFile )
oDoc = StarDesktop.loadComponentFromURL( cURL, "_blank", 0,
.... //error here because cURL is wrong
To remove this error, I hardcoded cURL of BOTH of doc file
and pdf file like
cURL = "file:///home/me/test.doc"
cURL = "file:///home/me/test.pdf"
so now the cURL should be alright but it always threw out error message at this line of code
oDoc.storeToURL( cURL, Array( MakePropertyValue( "FilterName", "writer_pdf_Export" ) ) )
###error message####
BASIC runtime error
an exception occurred
Type: com.sun.star.task.ErrorCodeIOException
Message:.
###end of message###
i.e, message is a dot. I do not know what is happening here.
Quote:
|
Originally Posted by jlinkels
Are you sure you don't have any spaces anywhere in the file name when you call from the command line?
What is the error message you get?
This is my code:
Code:
Sub SaveDocAsPDF( cFile )
Dim oDoc as object
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 )
cURL = ConvertToURL( cFile + ".pdf" )
' Save the document using a filter.
oDoc.storeToURL( cURL, Array( MakePropertyValue( "FilterName", "writer_pdf_Export" ) ) )
oDoc.close( True )
End Sub
And:
Code:
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 is the command line I use (from a script)
Code:
$OOFFICE -invisible "macro:///Standard.Conversions.SaveDocAsPDF($local_dir$fname.doc)"
The should be NO spaces between the parenthesis, like
SaveDocAsPDF( wrong ) because the the macro will try to open " wrong "
Note the spaces.
jlinkels
|