Closing a dialog problem

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Closing a dialog problem

Post 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
ms777
Volunteer
Posts: 176
Joined: Mon Oct 08, 2007 1:33 am

Re: Closing a dialog problem

Post by ms777 »

you cannot simply dispose an object, which is still in use.

Try

Code: Select all

MyDialog.endExecute()
User avatar
Lazy-legs
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Re: Closing a dialog problem

Post by Lazy-legs »

Ah! I see. Thank you very much, ms777!

Kind regards,
Dmitri
Post Reply