How to add a menu and manu items with VBA?

A

and

Hi,

How can I add a menu named "Correction" to the menu bar, and then add
with some menu items (to this new menu) that activate procedures from a
VBA module?

I can do this manually of course, with Tools > Customize, but I want to
do it by VBA code.

Now I have this recorder code that doesn't seem to work:

CommandBars("Menu Bar").Controls.Add Type:=msoControlPopup,
Before:=CommandBar.Controls.Count + 1

'the Count + 1 is written by hand, of course

CommandBars("Aangepast snelmenu 23187796").Controls.Add Type:= _
msoControlButton, Before:=1
CommandBars("Aangepast snelmenu 23187796").Controls.Add Type:= _
msoControlButton, Before:=2
CommandBars("Aangepast snelmenu 23187796").Controls.Add Type:= _
msoControlButton, Before:=3

Any Idea?
 
P

Paul Frenay

You need to identify the top level entry you have just added, by keepin
it in an appropriate object.


Set oNewMenu = CommandBars.Item("Menu Bar").Controls.Add _
(Type:=msoControlPopup, before:=oMnuBar.Controls.Count)

oNewMenu.Caption = "&Correction"

Set oNewButton = oNewMenu.Controls.Add(Type:=msoBarTypeMenuBar)
oNewButton.Caption = "Nieuwe Button
 

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