I have a peculiar problem happening, which I haven't been able to solve despite hours of googling & tinkering.
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="OnHomeRibbonLoad">
<ribbon startFromScratch="true">
<tabs>
<tab id="tab_Home" label ="Home" visible="true">
<group id="grp_Navigate" label="Navigate" visible="true">
<button id="btn_Tasks" label="Tasks" onAction="OnAction" visible="true" imageMso="ViewAllProposals" size="large" />
<toggleButton id="btn_Parties" label="Parties" onAction="OnAction" getPressed="GetPressed" visible="true" imageMso="ViewAllProposals" size="large" />
<button id="btn_Memos" label="Memos" onAction="OnAction" visible="true" imageMso="AccessTableIssues" size="large" />
</group>
</tab>
</tabs>
</ribbon>
<backstage onShow="OnBackstageShow">
<button id="btn_Login" label="Login" insertAfterMso="TabPrint" visible="true" getEnabled="GetEnabled" onAction="OnAction" isDefinitive="true"/>
<tab id="tab_Settings" label="Settings" insertAfterMso="TabPrint" visible="true" getEnabled="GetEnabled" ></tab>
<tab id="tab_Welcome" label="Welcome" insertAfterMso="TabPrint" visible="true" > </tab>
<tab idMso="TabPrint" visible="false"/>
<button idMso="ApplicationOptionsDialog" visible="false"/>
</backstage>
I have the above custom UI xml, and changed one of the buttons to be a togglebutton instead (id="btn_Parties"). All three buttons were working fine before, but after the togglebutton can't find its onAction callback function. The other two buttons trigger fine, but clicking the togglebutton results in an error saying... "Microsoft Access cannot run the macro or callback function 'OnAction'. Make sure the macro or function exists and takes the correct parameters".
Public Sub OnHomeRibbonLoad(ribbon As IRibbonUI)
Set HomeRibbon = ribbon
End Sub
Public Sub OnAction(control As IRibbonControl)
Select Case control.ID
Case "btn_Tasks"
MsgBox "Load TaskView"
Case "btn_Parties"
MsgBox "Load PartyView"
Case "btn_Memos"
MsgBox "Load MemoView"
Case Else
Debug.Print "Missing case in OnAction: " & control.ID
End Select
End Sub
Public Sub GetPressed(control As IRibbonControl, ByRef returnedVal)
Select Case control.ID
Case "tbtn_Parties"
returnedVal = IsPartiesLoaded
Case Else
returnedVal = True
Debug.Print "Missing case in GetEnabled: " & control.ID
End Select
End Sub
Is there something special about togglebutton that makes its OnAction event different to standard button?
If anyone can see where I'm going wrong, that would be much appreciated. Thanks.
The
onAction
callback for thetoggleButton
control should look like the following one:void OnAction(IRibbonControl control, bool pressed)
Sub OnAction(control As IRibbonControl, pressed As Boolean)
HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
Read more about the Fluent UI (aka Ribbon UI) in the following series of articles: