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

Last reviewed: September 2, 1997
Article ID: Q142360
The information in this article applies to:
  • Microsoft Excel for Windows 95, version 7.0

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)

REFERENCES

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


Additional query words: 7.00

Keywords : PgmOthr xlwin kbprb kbprg
Version : 7.00
Platform : WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 2, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.