在VBA中调用单词菜单键?

发布于 2025-02-07 04:26:14 字数 84 浏览 1 评论 0 原文

大家,

我是VBA的新手,想知道是否可以从WordAddin中执行菜单按钮。

不幸的是,我无法通过宏观记录。

everyone,

I am new to VBA and would like to know if it is possible to execute a menu button from a WordAddIn.

In the picture you can see which button I would like to execute using VBA.

Unfortunately, I can't record it via macro.

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

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

发布评论

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

评论(1

亚希 2025-02-14 04:26:14

单词对象模型允许使用 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-in buttons, toggleButtons, and splitButtons.

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.

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