Private myMenu As CommandBar
Private subControl1 As CommandBarButton
Public Sub NewMenu()
Dim myControl1 As CommandBarControl
Dim subControl1 As CommandBarControl
Set myMenu = Application.CommandBars.Add( _
name:=" My Menu Bar", _
Position:=msoBarTop, _
MenuBar:=True, _
Temporary:=True)
myMenu.Visible = True
Set myControl1 = myMenu.Controls.Add( _
Type:=msoControlPopup, _
ID:=1, _
Before:=1, _
Temporary:=True)
myControl1.Caption = "Menu Header &1"
Set subControl1 = myControl1.Controls.Add( _
ID:=1, _
Parameter:=" You have chosen to delete the custom menu!", _
Before:=1, _
Temporary:=True)
subControl1.Caption = "Delete Menu"
subControl1.Visible = True
subControl1.OnAction = "DeleteMenu"
End Sub
Private Sub DeleteMenu()
MsgBox subControl1.Parameter
myMenu.Delete
End Sub
|