@xld -- nice example. I forgot about ActivateTab


This is the callback module a little more cleaned up

One thing I REALLY don't like (philosophically) is having to use global variables to track status, but I've never found a way to avoid them


Option Explicit
Public bPressedA As Boolean, bPressedB As Boolean, bPressedC As Boolean
Public oRibbon As IRibbonUI

'Callback for customUI.onLoad
Sub OnRibbonLoad(ribbon As IRibbonUI)
    Set oRibbon = ribbon
End Sub
'Callback for tbA getLabel
Sub getToggleLabel(control As IRibbonControl, ByRef returnedVal)
    Select Case control.ID
        Case "tbA"
            returnedVal = IIf(bPressedA, "Hide A", "Show A")
        Case "tbB"
            returnedVal = IIf(bPressedB, "Hide B", "Show B")
        Case "tbC"
            returnedVal = IIf(bPressedC, "Hide C", "Show C")
    End Select
End Sub
'Callback for tbA getPressed
Sub getTogglePressed(control As IRibbonControl, ByRef returnedVal)
    Select Case control.ID
        Case "tbA"
            returnedVal = bPressedA
        Case "tbB"
            returnedVal = bPressedB
        Case "tbC"
            returnedVal = bPressedC
    End Select
End Sub
'Callback for tbA onAction
Sub onToggleAction(control As IRibbonControl, pressed As Boolean)
    Select Case control.ID
        Case "tbA"
            bPressedA = pressed
            oRibbon.Invalidate
        Case "tbB"
            bPressedB = pressed
            oRibbon.Invalidate
        Case "tbC"
            bPressedC = pressed
            oRibbon.Invalidate
    End Select
End Sub
'Callback for gA getVisible
Sub getGroupVisible(control As IRibbonControl, ByRef returnedVal)
    Select Case control.ID
        Case "gA"
            returnedVal = bPressedA
        Case "gB"
            returnedVal = bPressedB
        Case "gC"
            returnedVal = bPressedC
    End Select
End Sub
'Callback for bA1 onAction
Sub actionButton(control As IRibbonControl)
    MsgBox "You clicked Button = " & control.ID
End Sub