Finding Tabs in the Ribbon

T

tsract

I would like to be able to Enumerate the tabs in the Office 2007. Before my
clients upgraded to 2007 I was able to do things like this:

Sub oem()
Dim cmdBar As CommandBar
Dim mnuCtrl As CommandBarControl

'Enumerate non-Builtin Menus
'-----------------------------------------------------
For Each mnuCtrl In CommandBars.ActiveMenuBar.Controls
If mnuCtrl.BuiltIn = False And mnuCtrl.Enabled = True Then
MsgBox mnuCtrl.Caption
End If
Next

'Enumerate non-Builtin CommandBars
'--------------------------------------------------------
For Each cmdBar In Application.CommandBars
If cmdBar.BuiltIn = False And cmdBar.Enabled = True Then
MsgBox cmdBar.Name
End If
Next

End Sub


My addin needs to know what 3rd party tabs are currently loaded in the
Ribbon, but so far I can't find a simple solution. It appears that I have to
programmatically parse through a bunch of xml, but I don't know where to
begin to do that.

FYI: I'm writting the Addin in unmanaged c++; but I can read code examples
in vb, vba, and c#
 
C

Cindy M.

Hi Tsract,
My addin needs to know what 3rd party tabs are currently loaded in the
Ribbon, but so far I can't find a simple solution. It appears that I have to
programmatically parse through a bunch of xml, but I don't know where to
begin to do that.

The Ribbon UI was specifically designed to NOT include this functionality. A
Ribbon "belongs" to a specific document, template or COM Add-in and is not
supposed to be accessible outside that "container".

Possibly, you can leverage the Accessibility features to "read" the information
you're looking for:
http://msdn.microsoft.com/en-us/library/bb404170.aspx

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or reply
in the newsgroup and not by e-mail :)
 
T

tsract

Ouch! This would break my app;

I will check out the link you included for a possible work around;

Just so I am clear, if an OEM created a tab in the Ribbon, my Addin would
have no way of knowing that their tab exists?
 
C

Cindy M.

Hi Tsract,
Just so I am clear, if an OEM created a tab in the Ribbon, my Addin would
have no way of knowing that their tab exists?

Correct.

OTOH, if you were the "owner" of multiple Addins, each creating its own
controls, you could access these if the RibbonXML of all of them referenced
the same xmlns (Namespace). In that case, you can use the idQ attribute for
all elements you intend to "share" and manipulate them (getVisible, for
example) from all Addins.

I'm aware that may not be what you're looking for, but I throw it in for the
sake of the discussion, in case others may read this later.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
T

tsract

Disappointing as this is (we'll have to now come up with another strategy)
your response and link were both very informative.

Thank you,

- Germán
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top