Add Word menu problem

S

Susan Kong

Hi there,

I tried to add customized menu to WORD menu, but I can only add 7 submenu
items to the menu "Mymenu". Anybody knows why?

Here is my code:
Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
Temporary:=True)
newMenu.Caption = "Mymenu"
Set ctrl1 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=1)

With ctrl1
..Caption = "HP_Prepare_SRC"
..TooltipText = "HP_Prepare_SRC"
..Style = msoButtonCaption
..OnAction = "HP_Prepare_SRC"
End With

Set ctrl2 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=2)


With ctrl2
..Caption = "HP_Prepare_HHCHHK"
..TooltipText = "HP_Prepare_HHCHHK"
..Style = msoButtonCaption
..OnAction = "HP_Prepare_HHCHHK"
End With
.......

Thanks!

Best regards
Susan
 
C

Cindy M -WordMVP-

Hi Susan,

Try not assigning an ID value to the the control. From the Help for the
..Add method

"Id Optional Variant. An integer that specifies a ***built-in*** control.
If the value of this argument is 1, or if this argument is omitted, a blank
custom control of the specified type will be added to the command bar."
I tried to add customized menu to WORD menu, but I can only add 7 submenu
items to the menu "Mymenu". Anybody knows why?

Here is my code:
Set myMenuBar = CommandBars.ActiveMenuBar
Set newMenu = myMenuBar.Controls.Add(Type:=msoControlPopup, _
Temporary:=True)
newMenu.Caption = "Mymenu"
Set ctrl1 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=1)

With ctrl1
..Caption = "HP_Prepare_SRC"
..TooltipText = "HP_Prepare_SRC"
..Style = msoButtonCaption
..OnAction = "HP_Prepare_SRC"
End With

Set ctrl2 = newMenu.Controls _
.Add(Type:=msoControlButton, ID:=2)


With ctrl2
..Caption = "HP_Prepare_HHCHHK"
..TooltipText = "HP_Prepare_HHCHHK"
..Style = msoButtonCaption
..OnAction = "HP_Prepare_HHCHHK"
End With
.......

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 :)
 
S

Susan Kong

Thank you so much, Cindy! That works!

Susan

Cindy M -WordMVP- said:
Hi Susan,

Try not assigning an ID value to the the control. From the Help for the
Add method

"Id Optional Variant. An integer that specifies a ***built-in*** control.
If the value of this argument is 1, or if this argument is omitted, a blank
custom control of the specified type will be added to the command bar."


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)


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