RibbonXml togglebutton OnAction没有找到回调函数

问题描述 投票:2回答:1

我发生了一个特殊的问题,尽管谷歌上网和修修补补,我还是无法解决这个问题。

<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事件与标准按钮不同吗?

如果有人能看到我出错的地方,那将非常感激。谢谢。

vba ms-access callback togglebutton ribbonx
1个回答
2
投票

onAction控件的toggleButton回调应如下所示:

  • C#:void OnAction(IRibbonControl control, bool pressed)
  • VBA:Sub OnAction(control As IRibbonControl, pressed As Boolean)
  • C ++:HRESULT OnAction([in] IRibbonControl *pControl, [in] VARIANT_BOOL *pvarfPressed)
  • Visual Basic:Sub OnAction(control As IRibbonControl, pressed As Boolean)

在以下系列文章中阅读有关Fluent UI(aka Ribbon UI)的更多信息:

© www.soinside.com 2019 - 2024. All rights reserved.