I created a custom Ribbon in Excel with multiple ToggleButtons using Office RibbonX Editor. When I click them 1 by 1 everything works (display a certain meeting type on a calendar Yes or No).
I want to add two buttons to "select all" and "unselect all" ToggleButtons. All the meeting types are displayed or removed from my calendar but the status of the ToggleButtons doesn't change accordingly.
The following code forces a status when my Ribbon is changed. Each of the ToggleButtons calls this macro by using the "getpressed" syntax in XML:
XML:
<toggleButton id="TB1" onAction="OnTB1Click" getPressed="Option_Enabled"/>
VBA:
Sub Option_Enabled(control As IRibbonControl, ByRef returnedVal)
returnedVal = True
End Sub
I want to force a status of one specific toggleButton for which I have defined a keytip (TBa):
XML:
<toggleButton id="TB1" keytip="TBa" onAction="OnTB1Click" getPressed="Option_Enabled"/>
How can I call this toggleButton to force it's status?
I believe it must be close to my previous Option_Enabled macro but putting the right name to define the right IRibbonControl object. Do I have to use the id, the keytip?
OnTB1Clickwill run when you click the TB1 toggle button andOption_Enabledwill run when Excel draws your ribbon. SinceOption_Enabledalways returns True - your button will always appear pressed. You needOnTB1Clickto set some value that will be checked whenOption_Enabledis run to decide if the button should appear pressed or not. Then your "select all"/"unselect all"-buttons can set all those values to False and then invalidate the whole ribbon or the individual controls so they will be redrawn andOption_Enabledwill be run again.