[Solved] Enable/Disable a button from another button in Calc

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
aborbon
Posts: 2
Joined: Wed Sep 22, 2010 10:51 pm

[Solved] Enable/Disable a button from another button in Calc

Post by aborbon »

Hi,

I would like to change the property Enable of a command button (button1) during the execution of a macro from another command button (button2).

I mean, I need that button2 calls a macro to enable/disable button1.

I saw the example about how to change the enable property of the button who calls the macro http://user.services.openoffice.org/en/ ... nt#p118966 but I think my question is quite different.

Thanks!
Last edited by aborbon on Thu Sep 23, 2010 5:43 am, edited 1 time in total.
OpenOffice 3.2.0
Ubuntu 10.04 LTS Lucid Lynx
User avatar
Charlie Young
Volunteer
Posts: 1559
Joined: Fri May 14, 2010 1:07 am

Re: Enable/Disable a button from another button in Calc

Post by Charlie Young »

See attached.
 Edit: I guess I have Button 2 and Button 1 backwards, but that shouldn't be a big deal 
Attachments
DisableButton.ods
Enable/Disable Button
(10.32 KiB) Downloaded 834 times
Apache OpenOffice 4.1.1
Windows XP
aborbon
Posts: 2
Joined: Wed Sep 22, 2010 10:51 pm

Re: Enable/Disable a button from another button in Calc

Post by aborbon »

Thank you!!! That was really fast and helpfull! :super:

Well, I also found another solution in the spanish version of the forum http://user.services.openoffice.org/es/ ... B3n#p12072, here it is:

Code: Select all

Sub subButtonDisableButton2(Event As Object)
   Dim oForm As Object
   Dim oModelButton As Object
   oForm=Event.Source.Model.Parent      'We get the model of the form from the button who calls the macro
   oModelButton=oForm.GetByName("button2")      'Now we get the model of button2
   oModelButton.Enabled=False      'And we disable it!
End Sub
It only has a problem, both buttons have to be in the same form. But no problem for me, in my case they are! :D

:bravo:
OpenOffice 3.2.0
Ubuntu 10.04 LTS Lucid Lynx
Post Reply