
Sub GetPressed(control As IRibbonControl, ByVal returnedVal)
That should be ByRef, or the caller will never see the value.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I am trying to incorporate a "resume state" function in to an Excel Ribbon that has several toggle buttons. On close I save a list of Boolean variable to a spreadsheet and then on open it gathers them and applies them to the appropriate variables. That is working just fine. The problem lies when I try to send the Boolean through the getPressed callback function, the toggle buttons will press, run the onAction and then when the "getPressed" is called it reverts back to an unpressed state regardless of the Boolean value. If I remove the getPressed call from the XML everything works with exception to the ability to set the toggle button's state.
I am hoping someone can show me the error in my ways... thanks!
XML snippet:
<toggleButton
id="TB_Pause"
getLabel="GetLabel"
onAction="ButtonClicked"
getSize="GetSize"
image="Play_Pause"
getVisible="GetVisible"
getPressed="GetPressed"/>
VBA snippet:
Public Bool_Pause As Boolean
Dim myRibbon As IRibbonUI
Sub GetLabel(control As IRibbonControl, ByRef returnedVal)
Select Case control.id
Case "TB_Pause"
Select Case Bool_Pause
Case True: returnedVal = "Resume"
Case False: returnedVal = "Pause"
End Select
End Select
End Sub
Sub ButtonClicked(control As IRibbonControl, Optional ByRef pressed As Boolean)
Select Case control.id
Case "TB_Pause"
Bool_Pause = Not Bool_Pause
End Select
myRibbon.InvalidateControl (control.id)
End sub
Sub GetSize(control As IRibbonControl, ByRef returnedVal)
returnedVal = True
End Sub
Sub GetPressed(control As IRibbonControl, ByVal returnedVal)
Select Case control.id
Case "TB_Pause"
returnedVal = Bool_Pause
End Select
End Sub
Sub GetPressed(control As IRibbonControl, ByVal returnedVal)
That should be ByRef, or the caller will never see the value.