XL7: Run-time Error Adding Button to Toolbar

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

SYMPTOMS

In Microsoft Excel, when you use the Add method of the ToolbarButtons collection to add a button to a toolbar, you may receive the following error message:

   Run-time error '1004':
   Add method of Toolbars class failed

CAUSE

This behavior occurs if you add a button using a button ID number that is not valid or does not have a corresponding button face. For example, button ID value 146 does not have a corresponding button, and you receive the error message described above when you add a button using this button ID value.

In Microsoft Excel, the valid toolbar button ID values range from 1 to 248. However, not every value in this range is available. A table of available toolbar buttons and their button ID values is included in the Toolbar Button ID Values topic in the Visual Basic Reference. Some values are not available, and are correctly displayed in the table of available toolbar buttons as N/A.

REFERENCES

For more information about the available toolbar button ID values, click the Index tab in Visual Basic Reference Help, and type the following text

   ToolbarButton Object

and then double-click the selected text to go to the "ToolbarButton Object" topic. In the "ToolbarButton Object" topic, click the "Toolbar Button ID Values" topic.


Additional query words:
Keywords : PgmOthr kbprb
Version : 7.0
Platform : WINDOWS
Issue type : kberrmsg
Solution Type : kbworkaround


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 3, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.