Name

commandbar.Delete( )

Synopsis

Deletes a command bar. You can’t delete built-in command bars. Before creating a new command bar, it is a good idea to use Delete to make sure a command bar doesn’t already exist, as shown here:

Sub DeleteContextMenu( )
    ' Ignore error if command bar doesn't already exist.
    On Error Resume Next
    Application.CommandBars("ContextMenu1").Delete
    On Error GoTo 0
End Sub

Get Programming Excel with VBA and .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.