Ribbon preserve values on checkboxes

efernandes67

New member
Joined
Apr 13, 2017
Messages
2
Reaction score
0
Points
0
Hi,

I am just starting in ribbon customization and I am having a little problem. In the ribbon I inserted two check boxes (see attached file) that are used to hide columns. This part is working well I suppose. My problem is that when I save the file and reopen it the check boxes do not preserve the values when the workbook was saved. I saw a post using custom properties, but I think its a little advanced since I just start with ribbon customization.

What do I need to do to make it work?

Regards,
Elio Fernandes
 

Attachments

  • myCheckBox_03_stack.xlsm
    20.8 KB · Views: 36
Your getPressed routine fires for each control indivdually, but you are checking both controls in each iteration. Since there is only one returnedVal that can be fed back, you're overriding it with the state of whatever the last control is in the list.

This version of the routine uses a Select case to check the control name and should react a bit better for you:

Code:
Public Sub rxClass_getPressed(control As IRibbonControl, ByRef returnedVal)    Select Case control.ID
        Case Is = "chkClass12"
            With Worksheets("Sheet1").[oClass12]
                If .Value = True Then
                    returnedVal = True
                Else
                    returnedVal = False
                End If
            End With
        Case Is = "chkClass34"
            With Worksheets("Sheet1").[oClass34]
                If .Value = True Then
                    returnedVal = True
                Else
                    returnedVal = False
                End If
            End With
        Case Else
            MsgBox "I don't have a case for this control"
    End Select


End Sub
 
Back
Top