Deleting a menu item

Use the Delete method to delete custom or built-in menu items. The following statement deletes the Exit menu item from the File menu on the Worksheet menu bar:

CommandBars(1).Controls("File").Controls("Exit").Delete

To get this menu item back, use the Add method:

CommandBars(1).Controls("File").Controls.Add Type:=msoControlButton, Id:=752

Notice that I have to supply the Id for the Control that I add. The Id for the Exit menu item is 752. How did I figure that out? Before deleting the File menu, I typed the following statement in the Immediate window of the VBE (followed by pressing Enter to see the result):

? CommandBars(1).Controls("File").Controls("Exit").Id

0 0

Post a comment