How to add menu button to exisiting menubar

  • Thread starter Thread starter Mike P
  • Start date Start date
M

Mike P

I see a lot in previous posts on adding a whole new nenu...but I want
to add a new button (on the workbook open & remove on the workbook
before close events) to the Chart menu and assign a macro to it. I am
using XL2000. I am missing something in my attempts to add a single
button (not a pop-up) to an already existing menu.

Thanks in advance for the advice.

Mike
 
This works:

Sub AddNewItem()
Dim ctlNew As CommandBarControl
Set ctlNew = CommandBars("Chart Menu Bar").Controls _
("Chart").Controls.Add(msoControlButton, , , , True)
With ctlNew
.Style = msoButtonCaption
.Caption = "MyNewItem"
.Visible = True
.OnAction = "MyNewMacro"
End With
End Sub

Sub MyNewMacro()
MsgBox "Success!"
End Sub
 
Thanks, any idea on best way to delete the new menu button?

Actually, can someone describe the overal menu structure? That is
where I am having trouble understanding here. Thanks.
 
CommandBars("Chart Menu Bar").Controls _
("Chart").Controls("MyNewItem").Delete

I'll pass on trying to describe the overall menu structure as it is quite
complicated :-).
 
Thanks. I actually figured it out before you replyed, and that has
given me a better feel for how the menus are done.
 

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

Back
Top