In Calc - How to change properties on a pushbutton.

I have a pushbutton in calc I want to be disabled when sheet is opened . To set the property when designing is not a problem. Then when I go in the macro to check status of property and manipulate it I get an runtime error “Sub-procedure or function procedure not defined.” What is missing.

Sub ADTButton_Off
REM  *****  BASIC  *****

Dim ofForm As Object
Dim ocControl As Object
Dim oCollection As Object

Set ofForm = Forms("ATDButton_form")
Set ocControl = ofForm.Controls(0)

	If ocControl.hasProperty("ENABLED" , True) Then
		ocControl.setProperty("ENABLED", False)
	End If

End Sub

I have got it to work. I ended with this code:

Sub ADTButton_Off '------- make sure ADTButton is off
REM ***** BASIC *****

Dim oSheet As Object
Dim ofForm As Object
Dim ocControl As Object

oSheet = thiscomponent.sheets.getbyname(“Lønseddel”)
Set ofForm = oSheet.drawpage.Forms.GetByName(“ATDButton_form”)
Set ocControl = ofForm.getByIndex(1)

ocControl.Enabled = False

End Sub

This works with a trigger (open sheet).

Now I need to make a new trigger to a macro that checks conditions from changes in 1 of 3 cells in sheet. If I can not find anything in documentation I will make a new question.

Hi

You can try something like:

Sub ADTButton_Off REM BASIC

Dim ofForm As Object 
Dim ocControl As Object 
Dim oSheet As Object

oSheet = thiscomponent.sheets.getByName("Sheet1")

Set ofForm = oSheet.drawPage.Forms.getByName("ATDButton_form") 
Set ocControl = ofForm.getByIndex(0)

'If ocControl.Enabled Then '
'    ocControl.Enabled = false '
'else '
'    ocControl.Enabled = true   '
'End If '

ocControl.Enabled = not(ocControl.Enabled)

End Sub

Regards