在VBA中调用单词菜单键?
大家,
我是VBA的新手,想知道是否可以从WordAddin中执行菜单按钮。
在
不幸的是,我无法通过宏观记录。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
大家,
我是VBA的新手,想知道是否可以从WordAddin中执行菜单按钮。
在
不幸的是,我无法通过宏观记录。
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
单词对象模型允许使用 commandbars.executemso 通过执行由
idmso
参数标识的控件。在没有特定命令的对象模型的情况下,此方法很有用。在内置按钮
,togglebuttons
和splitbuttons
的控件上工作。但是在您的情况下,控件来自第三方加载项,该加载项不会揭示ID,
commandbars.executemso
方法找不到它并以编程方式调用命令。要完成工作,您可以考虑使用这是一种基于组件对象模型(COM)的技术,可改善可访问性AIDS与Microsoft Windows上运行的应用程序一起使用的方式。它提供了包含在操作系统中的动态链接库以及COM接口和API元素,可提供可靠的方法来揭示有关UI元素的信息。
另外,您可以联系加载项供应商,以提供可以从解决方案中调用的公共方法。这也是可能的解决方法,而不是在色带上调用UI元素。
The Word object model allows executing built-in ribbon controls using the CommandBars.ExecuteMso method which executes the control identified by the
idMso
parameter. This method is useful in cases where there is no object model for a particular command. Works on controls that are built-inbuttons
,toggleButtons
, andsplitButtons
.But in your case the control comes from a third-party add-in which doesn't expose IDs and the
CommandBars.ExecuteMso
method can't find it and invoke the command programmatically.To get the job done you may consider using the Microsoft Active Accessibility which is a Component Object Model (COM)-based technology that improves the way accessibility aids work with applications running on Microsoft Windows. It provides dynamic-link libraries that are incorporated into the operating system as well as a COM interface and API elements that provide reliable methods for exposing information about UI elements.
Also you may contact the add-in vendor for providing public methods that can be called from your solution. That's also a possible workaround instead of calling UI elements on the ribbon.