P
Peter Rooney
I want to add a new item "SysMan" to the left of "Help" on the Menu Bar.
This should contain a number of commands (including "Save") and sub menus,
one of which is "Create" which will have six menu items.
Sub AA_InsertMenu()
Dim cmbNewMenu As CommandBar
Dim ctlPopup As CommandBarPopup
Set cmbNewMenu = Application.CommandBars("Menu Bar")
With cmbNewMenu.Controls
Set ctlPopup = .Add(Type:=msoControlPopup, Before:=9)
With ctlPopup
.Caption = "&SysMan"
With .Controls.Add
.Caption = "&Save"
End With
End With
End Sub
I run the above procedure, and it creates "SysMan" with a menu item "Save"
on the menu bar no problem.
I then run another procedure to add the "Create" sub menu items to Sysman
Sub AA_InsertSubMenu()
Dim cmbMenu As CommandBar
Dim ctlPopup As CommandBarPopup
<< Set cmbMenu = Application.CommandBars("SysMan")>>
Set ctlPopup = cmbMenu.Controls.Add(Type:=msoControlPopup)
With ctlPopup
.Caption = "&Create"
With .Controls.Add
.Caption = "1. Core Tools"
End With
With .Controls.Add
.Caption = "&2 Service Management"
End With
With .Controls.Add
.Caption = "&3 Software Management"
End With
With .Controls.Add
.Caption = "&4 Storage Management"
End With
With .Controls.Add
.Caption = "&5 General"
End With
With .Controls.Add
.Caption = "&6 CIS"
End With
End With
End Sub
but when I run the procedure, I get the following message:
Invalid procedure call or argument
against the line of code bounded by the << >> above.
However, if I substitute "Tools" for "Sysman" in the above procedure, I get
a perfectly created sub-menu added to the bottom of The tools menu.
What am I doing wrong?
Also, how do I attach a particular macro procedure to a menu command item
e.g. "1. Core Tools" as above?
I await your massive knowledge, oh mighty MVP ers!
Cheers
Pete
This should contain a number of commands (including "Save") and sub menus,
one of which is "Create" which will have six menu items.
Sub AA_InsertMenu()
Dim cmbNewMenu As CommandBar
Dim ctlPopup As CommandBarPopup
Set cmbNewMenu = Application.CommandBars("Menu Bar")
With cmbNewMenu.Controls
Set ctlPopup = .Add(Type:=msoControlPopup, Before:=9)
With ctlPopup
.Caption = "&SysMan"
With .Controls.Add
.Caption = "&Save"
End With
End With
End Sub
I run the above procedure, and it creates "SysMan" with a menu item "Save"
on the menu bar no problem.
I then run another procedure to add the "Create" sub menu items to Sysman
Sub AA_InsertSubMenu()
Dim cmbMenu As CommandBar
Dim ctlPopup As CommandBarPopup
<< Set cmbMenu = Application.CommandBars("SysMan")>>
Set ctlPopup = cmbMenu.Controls.Add(Type:=msoControlPopup)
With ctlPopup
.Caption = "&Create"
With .Controls.Add
.Caption = "1. Core Tools"
End With
With .Controls.Add
.Caption = "&2 Service Management"
End With
With .Controls.Add
.Caption = "&3 Software Management"
End With
With .Controls.Add
.Caption = "&4 Storage Management"
End With
With .Controls.Add
.Caption = "&5 General"
End With
With .Controls.Add
.Caption = "&6 CIS"
End With
End With
End Sub
but when I run the procedure, I get the following message:
Invalid procedure call or argument
against the line of code bounded by the << >> above.
However, if I substitute "Tools" for "Sysman" in the above procedure, I get
a perfectly created sub-menu added to the bottom of The tools menu.
What am I doing wrong?
Also, how do I attach a particular macro procedure to a menu command item
e.g. "1. Core Tools" as above?
I await your massive knowledge, oh mighty MVP ers!
Cheers
Pete