简体   繁体   中英

Getting a button from Macro in Base (Libreoffice)

I'm trying to create a simple macro to control two buttons that have been placed in a form. They alternate positions, so they can be left pressed or unpressed, and the objective is to have only one of them pressed. My idea was to execute a macro every time one of the two is pressed, and the macro would be in charge of unpressing the other one.

Any ideas?

Thanks a lot!

The following code is from https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=34337 . It works for Base forms as well as Calc.

Sub subButtonDisableButton2(Event As Object)
   Dim oForm As Object
   Dim oModelButton As Object
   'We get the model of the form from the button who calls the macro
   oForm=Event.Source.Model.Parent
   'Now we get the model of button2
   oModelButton=oForm.GetByName("button2")
   'And we disable it!
   oModelButton.Enabled=False
End Sub

Or use radio buttons, which typically indicates that only one can be chosen at a time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM