使用 VBA 从 Office 2007 功能区读取值

发布于 2024-07-18 09:14:46 字数 303 浏览 7 评论 0原文

使用 VBA,我可以找出 Word 2007 功能区上文本(组合框)控件的值吗?

假设我想在“主页”选项卡中读取当前选择的字体名称。

我看过一个使用 IAccessible 的示例 接口与功能区进行一些交互(即枚举它),但似乎不可能读取控件值。 有没有其他方法可以做到这一点,或者VBA完全被锁定了?

Using VBA, can I find out the value of a text (combobox) control on the Word 2007 ribbon?

Say I'd want to read the currently selected font name in the "Home" tab.

I've seen an example using the IAccessible interface to do some interaction with the Ribbon (namely enumerating it), but it seems reading a control value is not possible. Is there another way to do it, or is VBA locked out completely?

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

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

发布评论

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

评论(1

幻想少年梦 2024-07-25 09:14:46

我认为您无法通过功能区来读取内置属性。
对于字体名称的具体示例,您可以使用以下内容。

Msgbox Application.Commandbars.Findcontrol(ID:=1728).Text

您也许可以调整该方法以获取其他信息。

I don't think you can get at the ribbon to read the built in properties.
For you specific example of Font name you can use the following.

Msgbox Application.Commandbars.Findcontrol(ID:=1728).Text

You maybe able to adpat the approach for other information.

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