XL7: Run-time Error Adding Button to Toolbar

ID: Q130583

The information in this article applies to:

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          : kbprb 
Version           : 7.0
Platform          : WINDOWS

Last Reviewed: September 4, 1997