如何获取功能区自定义选项卡 ID? [英] How to get Ribbon custom Tabs IDs?

查看:64
本文介绍了如何获取功能区自定义选项卡 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 Power Point 中使用自定义功能区,我需要遍历所有选项卡并获取它们的 ID.

I am working with a Custom Ribbon in Power Point, I need to iterate through all tabs and get the ID of them.

功能区包含从不同项目(C++、C#)作为插件添加的标签,我不知道它们的 ID.我正在使用 VBA 来处理从功能区触发的事件.

The Ribbon contains Tabs added from different projects (C++, C#) as addins and I don't know their IDs. I am using VBA to handle the events fired from the Ribbon.

如何使用 VBA 从功能区中的所有选项卡获取 ID?

How do I do to get the ID from all tabs in the Ribbon using VBA?

提前致谢.

推荐答案

使用返回 IAccessible 对象的 CommandBars("Ribbon") 访问功能区.您可以使用

The Ribbon is accessed using CommandBars("Ribbon") which returns an IAccessible object. You access tabs by using

AccessibleChildren _
            Lib "oleacc.dll" _
                (ByVal paccContainer As Object, _
                 ByVal iChildStart As Long, _
                 ByVal cChildren As Long, _
                       rgvarChildren As Variant, _
                       pcObtained As Long) _
            As Long

这将使用所有子元素(选项卡)的列表填充一个数组,这些子元素也是 IAccessible 对象.您获得的 ID 是字符串,您可以遍历每个 ID 的子项以获取子菜单项等.

This will fill an array with a list of all child elements (tabs) which are also IAccessible objects. The ID's you get are strings, and you can iterate through the children of each one to get submenu items and so on.

这非常复杂,因此完成此操作的最佳方法是从示例中工作.幸运的是,这里有一个闪亮的例子:http://www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.htm

It's quite complicated, so the best way to get this done would be to work from an example. Lucky for you there is a gleaming example here: http://www.wordarticles.com/Shorts/RibbonVBA/RibbonVBADemo.htm

仔细阅读那个代码.

这篇关于如何获取功能区自定义选项卡 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆