[Solved] Using Macro to open existing file in a new instance

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
johnnyideal
Posts: 6
Joined: Wed Nov 02, 2016 1:20 am

[Solved] Using Macro to open existing file in a new instance

Post by johnnyideal »

Hi, I am new with OO, I am trying to figure out how to open use a macro in a spreadsheet to open an existing saved spreadsheet in a new window. Thanks.
Last edited by johnnyideal on Thu Nov 10, 2016 9:39 pm, edited 1 time in total.
OpenOffice 4.1.2 on Windows 7
FJCC
Moderator
Posts: 9639
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Using Macro to open existing file in a new instance

Post by FJCC »

To open a file called CellRangeIndexing.ods that is on my desktop:

Code: Select all

FileName = "c:\users\fjcc\desktop\CellRangeIndexing.ods"
FileURL = convertToURL(FileName)
StarDesktop.loadComponentFromURL(FileURL, "_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.
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Using Macro to open existing file in a new instance

Post by Villeroy »

New instance as if it were a template?

Code: Select all

sub open_as_template(sPathName)
sURL = convertToURL(sPathName)
dim a(0) as new com.sun.star.beans.PropertyValue
a(0).Name = "AsTemplate"
a(0).Value = True
StarDesktop.loadComponentFromURL(sURL, 0, "_blank", a())
end sub
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Post Reply