Word2003 add-in|How to get a specific CommandBarPopUp of a command

F

Frenchy

Hi all,

I'd like to get a specific CommandBarPopup from a commandbar.

Here's the code I use to add a command bar and then to add a CommandBarPopup
to this CommandBar;

oCommandBars =
(CommandBars)applicationObject.GetType().InvokeMember("CommandBars",
BindingFlags.GetProperty , null, applicationObject ,null);

oStandardBar = oCommandBars.Add("Test",
Microsoft.Office.Core.MsoBarPosition.msoBarTop, missing, true);

Menu =
(CommandBarPopup)oStandardBar.Controls.Add(MsoControlType.msoControlPopup,
missing, missing, missing, true);

When I open a second document, I can't modify the CommandBarPopup "Menu", so
I'd like to get this object, but don't know how!?!

I tried this;

Menu =
(CommandBarPopup)appWord.CommandBars["Test"].GetType().InvokeMember("CommandBarPopup", BindingFlags.GetProperty , null, applicationObject ,null);

....Of cource it doesn't work...I didn't specify the name of the
CommandBarPopup...and I don't know how to do?

Help me please,


frenchy
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?RnJlbmNoeQ==?=,
When I open a second document, I can't modify the CommandBarPopup "Menu", so
I'd like to get this object, but don't know how!?!

I tried this;

Menu =
(CommandBarPopup)appWord.CommandBars["Test"].GetType().InvokeMember("CommandBarP
opup", BindingFlags.GetProperty , null, applicationObject ,null);
....Of cource it doesn't work...I didn't specify the name of the
CommandBarPopup...and I don't know how to do?
You'd probably have to request a CommandBarControl (the generic type). And then
you'd need to use an index (position on the commandbar) or the caption. In
VBA-speak:

Commandbars("Test").Controls("abc")

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
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 :)
 

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