How do I Change a Push-Button Label from Macro

I have a Calc spreadsheet on which I have used Form Design mode to add a Push-Button control to a sheet. Using the General tab of the Control’s Properties, I have assigned text to the button’s Label property. On the Control’s Properties Events tab, I have assigned a Basic Macro to be executed when the button is clicked. The macro code resides in the Standard Module of the spreadsheet itself (i.e. NOT in the My Macros Module.) When I click the button, the macro code is executed as desired.

I would like the Basic code in the Macro to be able, in some cases, to change the Button’s Label text and to be able to change its Enabled Property to “No” but I have not been able to find any documentation anywhere that provides guidance on how to access Form Controls such as the Push-Button when those controls exist directly on a sheet. Everything I have found assumes the Controls exist within a Dialog and describe how to access the Control through the Dialog and its associated Form. I do not want or need the complexity of a Dialog/Form. Can anyone provide an Example of LibreOffice Basic macro code that can access such a Control? Or provide link(s) to documentation that might help?

Chucko

OK, changing the Label is not difficult.

Sub onClick(oEvent As Variant)
Dim oSource As Variant
Dim oModel As Variant
  oSource = oEvent.Source
  oModel = oSource.getModel()
  If oModel.Label = "Enabled" Then 
  	oModel.Label = "Disabled"
  Else
  	oModel.Label = "Enabled"
  EndIf 
Rem ...some other actions
End Sub

But the second part of your question (Enabled/Disabled of the button) may cause problems.
Of course, we can write

oModel.Enabled = False

But how then do

oModel.Enabled = True 

if the button has already stopped responding to clicks?

Sweet! I should have known that I could access the Model through the Click Event itself, but I’m too new at LibreOffice Basic to have understood that I could access the Event by simply declaring it as an input to the Macro.

Your point about changing the Button’s Enabled property as a “one-way street” is well taken. I’ll have to re-think some of my design considerations. Thanks for your help.

===Edit===
I must have been fallen asleep. Juste noticed there was already an acceptede answer.
Still considering if I should delete this one.
May take some time if I fall asleep again. ;-).
===/Edit===

Your macro needs to have one parameter, say pEvent. Otherwise clicking the button would result in an error due to the wrong number of parameters.
The event parameter is a structure having a .Source property (for the binding to the Form) and this in turn a property .Model property giving access to the editable properties of the button. (Not to the events which are managed by the Form)
Via .Model you can access every relevant property (like .Label and the Boolean .Enabled e.g.) Concerning the well named .Tag property you need to know that it is badsly renamed “Additional information” in the editor for unknown reasons.
.Tag, in specific, I use to pass additional parameters (modifications) to the called Sub.

See this example: ask251077buttonExecuteActionExample_1.ods

Thanks for the info @Lupp. Very informative. I’ll investigate using .Tag too