Closing a dialog problem

Creating a macro - Writing a Script - Using the API

Closing a dialog problem

Postby Lazy-legs » Sun Mar 16, 2008 8:58 pm

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   Expand viewCollapse view
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
User avatar
Lazy-legs
 
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin

Re: Closing a dialog problem

Postby ms777 » Sun Mar 16, 2008 10:57 pm

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

Try
Code: Select all   Expand viewCollapse view
MyDialog.endExecute()
ms777
Volunteer
 
Posts: 131
Joined: Mon Oct 08, 2007 1:33 am

Re: Closing a dialog problem

Postby Lazy-legs » Mon Mar 17, 2008 12:38 am

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

Kind regards,
Dmitri
User avatar
Lazy-legs
 
Posts: 71
Joined: Mon Oct 08, 2007 1:33 am
Location: Århus-Berlin


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 6 guests