Microsoft KB Archive/104493
Microsoft Knowledge Base
XL: Macro Error Using Menu Customizing Function Commands
Last reviewed: June 30, 1997
Article ID: Q104493
The information in this article applies to:
- Microsoft Excel for Windows, version 5.0
- Microsoft Excel for the Macintosh, version 5.0
- Microsoft Excel for Windows 95, version 7.0
- Microsoft Excel for Windows NT, version 5.0
When you run a Microsoft Excel 4.0 macro that deletes a custom menu or command from the worksheet, macro sheet, or chart menu bar, you receive the following macro error:
Command or menu does not exist.
This behavior occurs when you run a macro that contains one of the menu function commands such as DELETE.COMMAND, if the command uses the bar_num argument with the value 1 or 2.
In Microsoft Excel 5.0, you can display either version 4.0 or version 5.0 menus. Because in Microsoft Excel 4.0, bar 1 refers to the standard menu bar for sheets and bar 2 refers to the chart menu bar, in version 5.0, 1 and 2 remain the identifiers for the version 4.0 menus. In Microsoft Excel 5.0, bar 10 refers to the standard menu bar for worksheets and macro sheets and bar 11 refers to the chart menu bar.
The ADD.MENU() and ADD.COMMAND() macro functions add menus and commands to the menu bar you specify for the bar_num argument. If you specify 1, the menu or command is also added to bar 10; if you specify bar 2, bar 11 is updated. When you add a command to a menu that only exists in Microsoft Excel 4.0, the command will be added to the version 5.0 menu that is in the same position as the version 4.0 menu. This means that you can run a version 4.0 customizing macro in Microsoft Excel 5.0 without having to use version 4.0 menus.
The DELETE.MENU() and DELETE.COMMAND() macro functions remove menus and commands from the menu bar you specify with the bar_num argument. However, when you use one of these functions to delete the custom menu or command from bar 1 or 2, the menu or command is not similarly deleted from bar 10 or 11. Additionally, the command causes a macro error when you are not using version 4.0 menus. This same problem occurs when you use the RENAME.COMMAND() and the ENABLE.COMMAND() functions.
To avoid receiving a macro error when you run a macro that contains a menu customizing macro function, use the appropriate bar_num value, 10 or 11 in the DELETE.MENU(), DELETE.COMMAND(), RENAME.COMMAND() or the ENABLE.COMMAND() function, to remove a menu or command from the version 5.0 menu bar. If you are removing a command from a menu that exists in 4.0 and not in version 5.0, you must specify the version 5.0 menu to which the command was added either by name or by position number.
Although you can run a version 4.0 macro that adds a command or menu in Microsoft Excel 5.0 without having to use version 4.0 menus, the best solution is to revise all of your customizing commands to work with version 5.0 menu bars.
For more information about Microsoft Excel Macro Functions, do the following:
- Choose Contents from the Help menu.
- Select Reference Information from the Microsoft Excel Help Contents screen.
- Select Microsoft Excel Macro Functions from the Reference Information screen.
- Select Alphabetical List Of Macro Functions or Macro Functions Listed by Category from the Microsoft Excel Macro Functions Contents screen.
Additional reference words: 7.00 5.00
Last reviewed: June 30, 1997