Johnny, the right place for your code (assuming you have modal dialogs) is where you did call dlg.execute().
This will return 0 for Cancel, something else (1) for OK. So if execute() doesn't return 0, do your stuff. Using macros on OK/Cancel button click would be wrong, because users can also use ESC (=cancel) or RETURN (=OK) for closing the dialog. HTH, Malte. Johnny Andersson wrote, On 01/24/07 19:01: > Hi! > > I am writing some StarBasic macros with OpenOffice.org Calc 2.1 on a Windows > XP system. I also created a few dialogs with some fields like date, time, a > combo box, an OK button and a cancel button. > > When creating the button I could set some things in the properties window, > like text on the button, font, size, position and a lot more. I also can set > it to act like one of the following: > > Standard button > OK button > Cancel button > Help button > > I tried different settings, and I realized that one big difference between > the OK setting and the Standard setting, is that when the button is set to > OK mode, the dialog is closed when the button is clicked. Great, that's just > what I want to happen. > > However, I also want some things to happen when the OK button is clicked, in > my case a few cells will be filled in depending on those fields mentioned > earlier, so I assigned the button to a macro that would do the job. I was > rather surprised when I noticed that the macro was never executed so I > thought that maybe I did something wrong, so I changed the button to a > standard button. Now the macro is called and everything works fine, except > that I have to click the cancel button to slose the window. > > So it seems to me that the Cancel button and the OK button does exactly the > same thing, is this true? If so, how is the OK button supposed to be used? > > I guess I can close the dialog with the macro and just let the button be a > standard button, but I still want to know about the OK button: Is this a > bug? Why can I assign the OK button to a macro when it'll never run anyway? > > I am confused... or maybe I just something really stupid or missed something > obvious... > > > > Best regards > > > Johnny > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
