This little thing I use in my code (partially in dutch for the labels). It creates a menu on auto_open (or workbook_open). First calls delete menu to prevent errors (if menu still exists) before creating the menu again. I use this only with one workbook open at the time (I think the other workbooks would have that bar to. If someone knows a way to disable the showing in the other workbooks, change the code and let me know.)
Sub Create_Menu()
Dim MyBar As CommandBar
Dim MyPopup As CommandBarPopup
Dim MyButton As CommandBarButton
Delete_Menu
Set MyBar = CommandBars.Add(Name:="Schuldbemiddeling", _
Position:=msoBarFloating, temporary:=True)
With MyBar
.Top = 50
.Left = 650
Set MyPopup = .Controls.Add(Type:=msoControlPopup)
With MyPopup
.Caption = "Werkbladen"
.BeginGroup = True
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Tabel Schuldeisers"
.Style = msoButtonCaption
''' msoButtonAutomatic, msoButtonIcon, msoButtonCaption, or msoButtonIconandCaption
.BeginGroup = True
.OnAction = "Tab_Schuldeisers"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Overzicht Schulden"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Over_Schulden"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Betalingen Schulden"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Bet_Schulden"
End With
End With
Set MyPopup = .Controls.Add(Type:=msoControlPopup)
With MyPopup
.Caption = "Afdruk/Nieuwe betaling"
.BeginGroup = False
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Nieuwe betaling"
.Style = msoButtonCaption
.BeginGroup = True
.OnAction = "Nw_Bet"
End With
Set MyButton = .Controls.Add(Type:=msoControlButton)
With MyButton
.Caption = "Afdrukken"
.Style = msoButtonCaption
.BeginGroup = False
.OnAction = "Afdrukken"
End With
End With
.Width = 130
.Visible = True
End With
End Sub
Sub Delete_Menu()
On Error Resume Next
CommandBars("My Menu").Delete
On Error GoTo 0
End Sub