[Solved] Assign Existing FileName Instead of private:factory

Creating a macro - Writing a Script - Using the API

[Solved] Assign Existing FileName Instead of private:factory

Postby npandit » Mon Nov 11, 2019 10:48 am

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
npandit
 
Posts: 13
Joined: Mon Nov 11, 2019 10:09 am

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

Postby JeJe » Mon Nov 11, 2019 5:03 pm

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.
Openoffice 4.1.2
Windows 8
JeJe
Volunteer
 
Posts: 626
Joined: Wed Mar 09, 2016 2:40 pm

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

Postby npandit » Tue Nov 12, 2019 6:37 am

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
npandit
 
Posts: 13
Joined: Mon Nov 11, 2019 10:09 am

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

Postby FJCC » Tue Nov 12, 2019 6:50 am

There is a convertToURL() function you can use to make a URL
Code: Select all   Expand viewCollapse view
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   Expand viewCollapse view
oDoc = oDesk.loadComponentFromURL(XMLurl, "_blank", 0, Array())
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7382
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

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

Postby npandit » Tue Nov 19, 2019 8:24 am

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
npandit
 
Posts: 13
Joined: Mon Nov 11, 2019 10:09 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 3 guests