Closing instance of OpenOffice?

Creating a macro - Writing a Script - Using the API

Closing instance of OpenOffice?

Postby t_t_u » Mon Sep 16, 2019 10:38 am

Hi,

I've got a task to migrate my piece of application from MS Excel to OpenOffice. My code creates a COM object of the OO application, gets a specified Calc sheet and retrieves data from it in the following way:

Code: Select all   Expand viewCollapse view
ServiceManager = New COMObject("com.sun.star.ServiceManager");
Desktop = ServiceManager.createInstance("com.sun.star.frame.Desktop");
Props1 = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue");
Props1 .Name = "AsTemplate";
Props1 .Value = True;
Args = New COMSafeArray("VT_VARIANT", 2);
Args.SetValue(0, Props1 );
Props2 = ServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue");
Props2.Name = "Hidden";
Props2.Value = True;
Args.SetValue(1,Props2);
Document = Desktop.LoadComponentFromURL(URL, "_blank", 0, Args);
Sheets = Document.getSheets();
Sheet = Sheets.getByIndex(1); // 2nd sheet of the file


My question is do I need to close/destroy created instance when my code has finished working with OO?

The reason I'm asking is because Excel had something like
Code: Select all   Expand viewCollapse view
ExcelObj.ActiveWorkbook.Close();
And being a newbie, I can't find something similar for OpenOffice. Thanks!
OpenOffice 4.1.6
t_t_u
 
Posts: 1
Joined: Mon Sep 16, 2019 10:29 am

Re: Closing instance of OpenOffice?

Postby robleyd » Mon Sep 16, 2019 11:41 am

You might find some useful information from a forum search for close window in the Macros and API section; in particular [Solved] Close OOo from a macro might be helpful
Cheers
David
Apache OpenOffice Developer Build 4.2.0 9820 - Slackware 14.2 - 64 bit
LibreOffice 6.0.7.3 - Slackware 14.2 - 64 bit
Apache OpenOffice 4.1.4 - Windows 7 Virtual machine
User avatar
robleyd
Moderator
 
Posts: 2985
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests