How do I make a button visible from a macro?

During the processing of an add data form I am using a macro to determine based on the data entered whether a button should become visible. The button is named “bSODb”. The code that I am using is includes the following (triggered by a different button):

	Me = oEvent.Source.Model.Parent
	Button = Me.GetByName("bSODb")
	ButtonCtrl = ThisComponent.CurrentController.getControl(Button)
	Msgbox ButtonCtrl.isVisible()
	ButtonCtrl.setVisible(True)
	Msgbox ButtonCtrl.isVisible()

The outcome of both Msgboxs is False, the button does not display, nor does it produce an error. What am I missing? (LO 5.2.7.2, OSX 10.12.5) Thanks.

I believe it should be -ButtonCtrl.Visible = True or False

This solution doesn’t change the Visibility nor generate an error message (The Msgbox after executing this command is still False).

You are trying to change the visibility in the View and it should be in the Model. This will work:

    Me = oEvent.Source.Model.Parent
	Button = Me.GetByName("bSODb")
    Msgbox Button.EnableVisible
    Button.EnableVisible = True
    Msgbox Button.EnableVisible

If this answers your question please click on the :heavy_check_mark: (upper left area of answer).

Perfect! Lots to learn with a new package. Thank you.