如何将 customUI 事件连接到 Word 2010 中的宏?
我有一个启用宏的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题出在
button
标记中的idQ
属性。我最初是从 UI 导出中获取这些的。一旦我将它们更改为id
,按钮事件就起作用了!The problem was the
idQ
attributes in thebutton
tags. I had originally taken these from a UI export. Once I changed them toid
, the button events worked!您不需要引用该模块。只需从两个
onAction
中删除SendAsEmail.
即可。You don't need to reference the module. Simply remove
SendAsEmail.
from both of youronAction
.