Sub AddNewMB()
Dim myCommandBar As CommandBar, myCommandBarCtl As CommandBarControl
Dim myCommandBarSubCtl As CommandBarControl
On Error GoTo AddNewMB_Err
Set myCommandBar = CommandBars.Add(Name:="Sample Menu Bar", Position:= _
msoBarTop, MenuBar:=True, Temporary:=False)
myCommandBar.Visible = True
myCommandBar.Protection = msoBarNoMove
Set myCommandBarCtl = myCommandBar.Controls.Add(Type:=msoControlPopup)
myCommandBarCtl.Caption = "Displa&y"
Set myCommandBarSubCtl = myCommandBarCtl.Controls.Add(Type:=msoControlButton)
With myCommandBarSubCtl
.Style = msoButtonIconAndCaption
.Caption = "S&le Menu Disable"
.FaceId = 59
.OnAction = "=SampleMenuDisable()"
.Parameter = 1
.BeginGroup = True
End With
AddNewMB_Err:
msgBox "Error " & Err.number & vbCr & Err.Description
Exit Sub
End Sub
Function SampleMenuDisable()
Application.CommandBars("Sample Menu Bar").Visible = False
Application.CommandBars("Menu Bar").Visible = True
End Function
|