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

ID: Q142360

The information in this article applies to:

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:

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)

REFERENCES

"Microsoft Excel Function Reference," version 4.0, page 8

Additional query words: 7.00

Keywords          : xlwin 
Version           : 7.00
Platform          : WINDOWS

Last Reviewed: September 3, 1997