VBA code for custom menubar

E

Edward

Hi everybody,
I'm creating custom toolbar with some buttons and also a menubutton , I know
how to create regular button but I can't find a way to add a menubuton using
VBA code ( I can't find its name in VBA references)

With objCommandBar.Controls

Set objCommandButton = .Add(msoControlButton)<--- what should I use
here
....
for menu button
 
G

Gordon Bentley-Mix

Edward,

I think maybe what you're looking for is msoControlPopup. It seems to
display a button that looks like the "menu" type buttons on some of the
standard toolbars in that it has the little "down arrow" to the right of the
caption. However, when I query the .Type property of this button, it returns
a value of 10; this doesn't appear to be the same as the .Type property (13
or 14) of the similar buttons on a standard toolbar. When I fiddled with my
code to use a numeric constant, it works with 10 but fails with 13 or 14.
Other numeric constants, such as 1 or 4, do work, but 20, which appears to be
very similar to 4, does not. Curiouser and curiouser...

In addition, I cannot figure out how to add "menu items" to the button, so I
cannot be sure that this really is the right type of button. However, at
least it's a start, and maybe one of the other bright sparks here can give
you more direction.
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.
 
E

Edward

Thanks. After I posted my question i did some research and I did almost the
same tests that you did , yes the correct name is msoControlPopup and I also
saw the same inconsistencies that you mentioned
adding items to that popup menu is easy

Set myCPup = myCB.Controls.Add(Type:=msoControlPopup)

Set myCBtn = myCPup.Controls.Add(Type:=msoControlButton)
With myCBtn
.Caption = "Blue"
.Style = msoButtonIconAndCaption
.Picture = frmImage.imgDarkBlue.Picture

End With
 

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