Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
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
###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
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195
Rep:
This is gonna be a tough one, isn't it? When the code runs on one machine and is supposedly correct, it is difficult to change it into something else which is correct as well.
There might be a few things to narrow down where the error is.
1. Don't open the document as "hidden". Now you can see if the document is opened correctly. Use this call:
2. If the document opens correctly, try to do another operation on oDoc. I don't know which one for a writer document, but you should be able to find something in the forum you referred to before. If you do that, you know for sure oDoc has a value and can be used.
3. In any way, single step thru your code and inspect all objects if possible. There is a tool available which you can use to inspect objects, X-ray or so. You'll find pointers on that same forum.
4. Single step thru the MakePropertyValue function to see if everything is set and returned as expected.
Almost all problems I had with these kind of macros is that I tried to use something which was not there, like to open a non-existent file, or to select a non existent sheet in a workbook, or to store something in a non-existent directory.
The cURL you specified looks good. Did you try to get cURL from
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.