Microsoft KB Archive/142360

= ADD.COMMAND Fails if You Use Menu Item Name for Position =

Article ID: 142360

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 95 Standard Edition

-



This article was previously published under Q142360



SYMPTOMS
In Microsoft Excel version 7.0, when you use the Microsoft Excel 4.0 macro language ADD.COMMAND function, if you use menu item names for the position argument, this function may fail, and you may receive the following error message:

Command or menu does not exist.



CAUSE
The Excel 4.0 Macro language ADD.COMMAND function fails if you use non- existent menu item names for the position argument. Microsoft Excel 7.0 menus are different from menus in previous versions of Microsoft Excel.



RESOLUTION
To work around this problem, you can prevent the ADD.COMMAND function from failing by doing either of the following:


 * Use the position of the index numbers instead of the menu item name for the position argument, as shown in the example in the "More Information" section of this article. -or-


 * Leave position arguments empty. When you do so, Microsoft Excel adds the new menu command to the end of the menu.



STATUS
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.



MORE INFORMATION
Microsoft provides macro examples for illustration only, without warranty either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. This macro is provided 'as is' and Microsoft does not guarantee that the following code can be used in all situations. Microsoft does not support modifications of the code to suit customer requirements for a particular purpose.

Because Index is not a menu item on the Help menu in Microsoft Excel 7.0, the following code will fail: =ADD.COMMAND(1,"Help",C1:D1,"Index") To make the macro code work, use a number for the position argument, as in the following example: =ADD.COMMAND(1,"Help",C1:D1,1)

