When creating a commandbar with the code below it is only a temporarily
commandbar and that is great, however it is only temp in that sense that you
have to close the Excel application down and reopen before the commandbar
removed.

Is there away to have the commandbar removed as soon as you close the
worksheet that has the macro and command?


Dim oCb As CommandBar
Dim oCtl As CommandBarButton

Set oCb = Application.CommandBars("Worksheet Menu Bar")
With oCb
Set oCtl = .Controls.Add( _
Type:=msoControlButton, _
temporary:=True)
oCtl.Caption = "myButton"
oCtl.Style = msoButtonCaption
oCtl.OnAction = "myMacro"
End With


Thank you in advance for you help.

Rene