我发生了一个特殊的问题,尽管谷歌搜索了几个小时,但我还是无法解决这个问题。修修补补。
<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,并将其中一个按钮更改为togglebutton(id =“btn_Parties”)。之前所有三个按钮都工作正常,但是在togglebutton之后找不到它的onAction回调函数。其他两个按钮触发正常,但单击togglebutton导致错误说...“Microsoft Access无法运行宏或回调函数'OnAction'。确保宏或函数存在并采用正确的参数”。
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事件与标准按钮不同?
如果有人能看到我出错的地方,那将非常感激。谢谢。
答案 0 :(得分:3)
onAction
控件的toggleButton
回调应如下所示:
void OnAction(IRibbonControl control, bool pressed)
Sub OnAction(control As IRibbonControl, pressed As Boolean)
HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
Sub OnAction(control As IRibbonControl, pressed As Boolean)
在以下系列文章中阅读有关Fluent UI(又名Ribbon UI)的更多信息: