We recommend using Visual Studio 2017
This documentation is archived and is not being maintained.

Deleting a Command Bar

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

You can delete toolbars and menu bars from the Customize dialog box or by using Microsoft® Visual Basic® for Applications (VBA). You can delete pop-up menus only by using VBA. Use the Delete method of the CommandBars collection to remove an existing command bar from the collection. The following procedure illustrates one way to delete a CommandBar object:

Function CBDeleteCommandBar(strCBarName As String) As Boolean
   On Error Resume Next
End Function

An error will occur if strCBarName is not the name of an existing command bar. The procedure uses the On Error Resume Next statement to ignore this error because, if an error occurs, it means there is nothing to delete. In addition, it could mean you tried to delete a built-in command bar, such as Standard, which cannot be deleted.

See Also

Working with Command Bars | Manipulating Command Bars and Command Bar Controls with VBA Code | Getting Information About Command Bars and Controls | Creating a Command Bar | Hiding and Showing a Command Bar | Copying a Command Bar | Preventing Users from Modifying Custom Command Bars | Working with Personalized Menus | Working with Images on Command Bar Buttons | Working with Command Bar Controls | Working with Command Bar Events