Page 1 of 1

Closing a dialog problem

Posted: Sun Mar 16, 2008 8:58 pm
by Lazy-legs
Hello,

Yet another silly OpenOffice.org Basic-related question from yours truly. I have two macros in the same module, where Macro1 displays a dialog box. The Macro2 must close the dialog box from Macro1 before it does certain actions. The way I try to solve the problem is to make the Dialog a public variable and then use the Dialog.Dispose command in Macro2. The problem is that it doesn't work: every time I run Macro2, it crashes OpenOffice.org. Here is the code:

Code: Select all

Public MyDialog

Sub Macro2()

MyDialog.Dispose

MsgBox "Hello world!"

End Sub

Sub Macro1()

exitOK=com.sun.star.ui.dialogs.ExecutableDialogResults.OK
DialogLibraries.LoadLibrary("Standard")
Library=DialogLibraries.GetByName("Standard")
TheDialog=Library.GetByName("Dialog1")

MyDialog=CreateUnoDialog(TheDialog)

MyDialog.Execute

End Sub
What am I doing wrong?

Thank you!

Kind regards,
Dmitri

Re: Closing a dialog problem

Posted: Sun Mar 16, 2008 10:57 pm
by ms777
you cannot simply dispose an object, which is still in use.

Try

Code: Select all

MyDialog.endExecute()

Re: Closing a dialog problem

Posted: Mon Mar 17, 2008 12:38 am
by Lazy-legs
Ah! I see. Thank you very much, ms777!

Kind regards,
Dmitri