Page 1 of 1

Closing instance of OpenOffice?

PostPosted: Mon Sep 16, 2019 10:38 am
by t_t_u
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!

Re: Closing instance of OpenOffice?

PostPosted: Mon Sep 16, 2019 11:41 am
by robleyd
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