Deleting a menu from a menu bar

To delete a menu, use the Delete method. The following example deletes the menu in the Worksheet Menu Bar whose caption is Budgeting. Notice that I use On Error Resume Next to avoid the error message that appears if the menu does not exist.

Sub DeleteMenu()

On Error Resume Next

CommandBars(1).Controls("Budgeting").Delete End Sub

Recall that the Budgeting menu was given a caption by using this instruction: NewMenu.Caption = "&Budgeting"

When you reference a menu by using its caption, the ampersand is optional.

0 0

Post a comment