In Microsoft Excel, in a Visual Basic macro, you can add a new menu command
to a menu by using a line of code similar to the following:
MenuBars(xlWorksheet).Menus("View").MenuItems.Add Caption:="Test", _
Before:="Toolbars..."
This line of code adds a new menu command,
Test, above the
Toolbars... menu command on the
View menu.
You can also delete a menu command by using a line of code similar to the
following:
MenuBars(xlWorksheet).Menus("View").MenuItems("Toolbars...").Delete
In each of the lines of code, the menu command
Toolbars... is referred by its exact name. In Microsoft Excel 97 and later, the names of some menu commands are changed. The new names may cause problems if macro code refers to these menu items by name.
The two lines of code work correctly in versions of Microsoft
Excel earlier than Excel 97. However, they do not work correctly in Microsoft Excel 2000, because the menu command
Toolbars... is renamed
Toolbars (no ellipsis).
The following menu commands are changed in Microsoft Excel 97 and later.
Microsoft Excel 5.0, 7.0 Microsoft Excel 97, 2000
Menu menu command menu command
------------------------------------------------------------------
View Toolbars... Toolbars
Insert Chart Chart...
Insert Note... Comment
Data PivotTable... PivotTable Report...
(in Excel 97)
-or-
PivotTable and
PivotChart Report
(in Excel 2000)
sheet tab Rename... Rename
shortcut
menu*
* This menu is the xlWorkbookTab shortcut menu.