RibbonXml togglebutton OnAction 找不到回调函数
RibbonXml togglebutton OnAction not finding callback function
我遇到了一个特殊的问题,尽管谷歌搜索和修改了数小时,但我仍无法解决。
<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>
我有上面的自定义 UI xml,并将其中一个按钮更改为切换按钮 (id="btn_Parties")。三个按钮之前都可以正常使用,但是切换按钮之后找不到它的 onAction 回调函数。其他两个按钮触发正常,但单击切换按钮会导致错误提示... "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
togglebutton 是否有一些特殊之处使其 OnAction 事件不同于标准按钮?
如果有人能看出我哪里错了,那将不胜感激。谢谢。
toggleButton
控件的 onAction
回调应如下所示:
- C#:
void OnAction(IRibbonControl control, bool pressed)
- VBA / VB:
Sub OnAction(control As IRibbonControl, pressed As Boolean)
- C++:
HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
在以下系列文章中阅读有关 Fluent UI(又名功能区 UI)的更多信息:
我遇到了一个特殊的问题,尽管谷歌搜索和修改了数小时,但我仍无法解决。
<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>
我有上面的自定义 UI xml,并将其中一个按钮更改为切换按钮 (id="btn_Parties")。三个按钮之前都可以正常使用,但是切换按钮之后找不到它的 onAction 回调函数。其他两个按钮触发正常,但单击切换按钮会导致错误提示... "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
togglebutton 是否有一些特殊之处使其 OnAction 事件不同于标准按钮?
如果有人能看出我哪里错了,那将不胜感激。谢谢。
toggleButton
控件的 onAction
回调应如下所示:
- C#:
void OnAction(IRibbonControl control, bool pressed)
- VBA / VB:
Sub OnAction(control As IRibbonControl, pressed As Boolean)
- C++:
HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
在以下系列文章中阅读有关 Fluent UI(又名功能区 UI)的更多信息: