Close the parent dialog of a control on a *Calc* dialog

Hello and thank You for this wonderful office suite!

Right now I am trying to create a custom dialog in LO Calc with Basic. I managed to do many things by googling but I cannot discern how can I close the parent dialog after a user selects an element from a combo box called oPrieksmetsBox. A macro is assigned to the “Change Text” event for the combo box. Currently the code is as follows (it writes the selected value – the name of a sheet – into a cell on another sheet (not in the list), selects that sheet and then should close the dialog):

sub inscribeVal(oEvent as Object)
	Dim oSheet as Object, oDocum as Object
	oDocum = ThisComponent
	oPrieksmetsBox = oEvent.Source '.getModel()
	'msgbox(oPrieksmetsBox.Text)
	oSheet = oDocum.Sheets.getByName("Titullapa")
	oSheet.getCellByPosition(48, 12).Formula = oPrieksmetsBox.Text  'column, row
	on error goto ErrorHnadll
		oDocum.CurrentController.Select(oDocum.Sheets.getByName(oPrieksmetsBox.Text))
		oPrieksmetsBox.Parent.endExecute()
		Exit Sub
	ErrorHnadll:
		MsgBox("Tāda lapa neeksistē!")
end sub

I have also tried to replace the culprit line:
oPrieksmetsBox.Parent.endExecute()
with
oPrieksmetsBox.Parent.Parent.CurrentController.endExecute()
but to no avail. Also, getParent() does not work instead of Parent – in both cases I am presented with the “No such property or method” error message (if I comment out the custom error handler, that is). Both endExecute() and dispose() methods were tried (but at this point it does not matter, as we are not getting over the “Parent”).

As You can guess, I am trying to compile this from some posts I found about the forms in Base but these apparently are handled in a very different way…

As an alternative, I could have drawn a button which gets the information from its peer combo box and has the “OK” type. But this still requires getting to the parent… am I right?

Please upload a sample file together with the embedded macro code here.

macro_example.ods (16.6 KB)
Please see the sample file attached. Thank You for Your attention!

try oPrieksmetsBox.Context.endExecute

2 Likes

Thank You very much, it worked!