How to get Ribbon custom Tabs IDs?

僤鯓⒐⒋嵵緔 提交于 2019-11-27 02:53:48

问题


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.


回答1:


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

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.

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

Pore through the code on that one.



来源:https://stackoverflow.com/questions/615482/how-to-get-ribbon-custom-tabs-ids

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!