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.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…