如何将 customUI 事件连接到 Word 2010 中的宏?

发布于 2024-10-31 17:09:10 字数 1290 浏览 3 评论 0原文

我有一个启用宏的 MS Word 2010 文档模板(.dotm 文件)。我正在通过 .dotm 存档中的 customUI\customUI14.xml 文件嵌入一些自定义功能区 UI 组件。

控件显示正常,但我无法将 XML 中描述的 onAction 事件与模板中定义的任何宏链接起来。我认为方法签名是正确的,但我在 XML 中引用它们的方式一定是错误的。我做错了什么?

这是 XML:

<mso:customUI xmlns:x2="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:x1="DPOfcX.DocumentRibbon" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
    <mso:ribbon>
        <mso:tabs>
            <mso:tab idQ="mso:TabHome">
                <mso:group id="TestGroup" label="TestGroup" autoScale="true">
                    <mso:button onAction="SendAsEmail.SendAsEmailRibbon" idQ="x2:TestSendAsEmail" label="Send As Email" imageMso="ListMacros" visible="true"/>
                    <mso:button onAction="SendAsEmail.ShowFormRibbon" idQ="x2:TestShowForm" label="Enter Letter Data" imageMso="ListMacros" visible="true"/>
                </mso:group>
            </mso:tab>
        </mso:tabs>
    </mso:ribbon>
</mso:customUI>

这是 SendAsEmail 模块中的方法签名:

Sub ShowFormRibbon(IControl As IRibbonControl)

End Sub

Sub SendAsEmailRibbon(IControl As IRibbonControl)

End Sub

I have a MS Word 2010 macro-enabled document template (.dotm file). I am working on embedding some custom Ribbon UI components by means of a customUI\customUI14.xml file within the .dotm archive.

The controls show up fine, but I am unable to link up the onAction events described in the XML with any of the macros defined in the template. I think the method signatures are correct, but I must be referencing them incorrectly in the XML. What am I doing wrong?

Here's the XML:

<mso:customUI xmlns:x2="http://schemas.microsoft.com/office/2009/07/customui/macro" xmlns:x1="DPOfcX.DocumentRibbon" xmlns:mso="http://schemas.microsoft.com/office/2009/07/customui">
    <mso:ribbon>
        <mso:tabs>
            <mso:tab idQ="mso:TabHome">
                <mso:group id="TestGroup" label="TestGroup" autoScale="true">
                    <mso:button onAction="SendAsEmail.SendAsEmailRibbon" idQ="x2:TestSendAsEmail" label="Send As Email" imageMso="ListMacros" visible="true"/>
                    <mso:button onAction="SendAsEmail.ShowFormRibbon" idQ="x2:TestShowForm" label="Enter Letter Data" imageMso="ListMacros" visible="true"/>
                </mso:group>
            </mso:tab>
        </mso:tabs>
    </mso:ribbon>
</mso:customUI>

Here are the method signatures in the SendAsEmail module:

Sub ShowFormRibbon(IControl As IRibbonControl)

End Sub

Sub SendAsEmailRibbon(IControl As IRibbonControl)

End Sub

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谁人与我共长歌 2024-11-07 17:09:10

问题出在 button 标记中的 idQ 属性。我最初是从 UI 导出中获取这些的。一旦我将它们更改为id,按钮事件就起作用了!

The problem was the idQ attributes in the button tags. I had originally taken these from a UI export. Once I changed them to id, the button events worked!

不打扰别人 2024-11-07 17:09:10

您不需要引用该模块。只需从两个 onAction 中删除 SendAsEmail. 即可。

You don't need to reference the module. Simply remove SendAsEmail. from both of your onAction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文