Adding selections and submenu items to the Budgeting menu
Sub CreateMenu()
Dim HelpMenu As CommandBarControl
Dim NewMenu As CommandBarPopup
Set HelpMenu = CommandBars(1).FindControl(ID:=30010)
If HelpMenu Is Nothing Then
Set NewMenu = CommandBars(1).Controls _
.Add(Type:=msoControlPopup, temporary:=True)
Else
Set NewMenu = CommandBars(1).Controls _
.Add(Type:=msoControlPopup, Before:=HelpMenu.Index, _
temporary:=True)
End If
NewMenu.Caption = "&ItemMenu"
Set MenuItem = NewMenu.Controls.Add _
(Type:=msoControlButton)
With MenuItem
.Caption = "&Item1..."
.FaceId = 162
.OnAction = "Macro1"
End With
Set MenuItem = NewMenu.Controls.Add _
(Type:=msoControlButton)
With MenuItem
.Caption = "&Item2..."
.FaceId = 590
.OnAction = "Macro2"
End With
Set MenuItem = NewMenu.Controls.Add _
(Type:=msoControlPopup)
With MenuItem
.Caption = "Item &Charts"
.BeginGroup = True
End With
Set SubMenuItem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With SubMenuItem
.Caption = "Item &Variance"
.FaceId = 420
.OnAction = "Macro3"
End With
Set SubMenuItem = MenuItem.Controls.Add _
(Type:=msoControlButton)
With SubMenuItem
.Caption = "&Summary"
.FaceId = 422
.OnAction = "Macro4"
End With
End Sub
Related examples in the same category