[Solved] Assign Existing FileName Instead of private:factory

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
npandit
Posts: 16
Joined: Mon Nov 11, 2019 10:09 am

[Solved] Assign Existing FileName Instead of private:factory

Post by npandit »

I have merged the Saving data to calc code with my exisiting code.However while saving the file in my exisitng code i have written as Save(XMLFilename) XMLFilename will be used and assigned everywhere in the project
But with Open Office i tried oDoc = oDesk.loadComponentFromURL(XMlfilename", "_blank", 0, arg) But it is giving error and this line
oDoc = oDesk.loadComponentFromURL("private:factory/scalc", "_blank", 0, arg)
Opens a new File always .I jus want it to ASSIGN IT with xmlfilename
Like Border,Image should be stored in the file whichever user selects and load that is XMLFilename
Can anybody suggest how to do this?
Last edited by Hagar Delest on Tue Nov 19, 2019 8:59 am, edited 2 times in total.
Reason: tagged solved
Open Office 4.1.7
JeJe
Volunteer
Posts: 2764
Joined: Wed Mar 09, 2016 2:40 pm

Re: Assign Existing FileName Instead of private:factory/sca

Post by JeJe »

oDoc = oDesk.loadComponentFromURL(XMlfilename", "_blank", 0, arg)

You have a " at the end of XMlfilename which shouldn't be there

Edit: assuming XMlfilename is a variable. If its a string you need another " in front of it. Make sure the path is a URL.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
npandit
Posts: 16
Joined: Mon Nov 11, 2019 10:09 am

Re: Assign Existing FileName Instead of private:factory/sca

Post by npandit »

I did try putting " before XMLFilename but it gives error
Also the XMLFilename is normal path not a URL
What to do?
Open Office 4.1.7
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Assign Existing FileName Instead of private:factory/sca

Post by FJCC »

There is a convertToURL() function you can use to make a URL

Code: Select all

XMLurl = convertToURL(XMlfilename)
oDoc = oDesk.loadComponentFromURL(XMLurl, "_blank", 0, arg)
A couple of questions:
1. Is the variable really XMlfilename and not XMLfilename?
2. How is arg defined? If you just need an empty array as the last parameter of loadComponentFromURL(), you can use Array().

Code: Select all

oDoc = oDesk.loadComponentFromURL(XMLurl, "_blank", 0, Array())
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
npandit
Posts: 16
Joined: Mon Nov 11, 2019 10:09 am

Re: Assign Existing FileName Instead of private:factory/sca

Post by npandit »

Thank you all for the help
I used this line :
oDoc = oDesk.loadComponentFromURL("file:///" & XMLFilename.Replace("\", "/"), "_default", 0, arg)
and it worked
It now opens an existing file
Open Office 4.1.7
Post Reply