Ask Your Question
0

In Calc - How to change properties on a pushbutton.

asked 2019-03-02 13:24:16 +0100

Jfi459 gravatar image

updated 2019-03-02 14:04:17 +0100

pierre-yves samyn gravatar image

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
edit retag flag offensive close merge delete

Comments

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.

Jfi459 gravatar imageJfi459 ( 2019-03-04 01:11:17 +0100 )edit

1 Answer

Sort by » oldest newest most voted
0

answered 2019-03-02 14:04:01 +0100

pierre-yves samyn gravatar image

updated 2019-03-02 14:04:47 +0100

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

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-03-02 13:24:16 +0100

Seen: 53 times

Last updated: Mar 02