8

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

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.

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

Thanks in advance.

4

1 回答 1

9

使用返回 IAccessible 对象的 CommandBars("Ribbon") 访问功能区。您通过使用访问选项卡

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 的子项以获取子菜单项等。

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

功能区选项卡

仔细阅读那个代码。

于 2011-01-06T15:59:09.420 回答