[Solved] Disable button on mainform

Creating and using forms
Post Reply
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

[Solved] Disable button on mainform

Post by gkick »

Hi,

anyone having an example of toggling a buttons enabled and or visible property
Thanks
Last edited by gkick on Thu Oct 17, 2019 4:46 am, edited 1 time in total.
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Disable button on mainform

Post by UnklDonald418 »

Your macro must first find the oForm object, and that depends on the structure of the form and how the macro is triggered. Once you have the oForm object then to toggle the Enabled property use

Code: Select all

oButton = oForm.getByName("NameOfTargetButton")

If oButton.Enabled = TRUE then
   oButton.Enabled = FALSE
Else
   oButton.Enabled = TRUE
End if
or if you want to toggle visibility use

Code: Select all

oButton = oForm.getByName("NameOfTargetButton")

If oButton.EnableVisible = TRUE then
   oButton.EnableVisible = FALSE
Else
   oButton.EnableVisible = TRUE
End if
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
gkick
Posts: 324
Joined: Wed Aug 07, 2019 5:24 pm
Location: Chile

[Solved]Re: Disable button on mainform

Post by gkick »

Thank you UnclDonald ! Had the first piece of code working and the button came back at restarting base. Appreciate your time and help
regards
Gerhard
Libre Office 6.4.6 on Windows 10 HSQL 2.51 backend
Post Reply