Article ID: 141766
Article Last Modified on 10/10/2006
APPLIES TO
- Microsoft Excel 97 Standard Edition
- Microsoft Excel 95 Standard Edition
- Microsoft Excel 5.0 Standard Edition
- Microsoft Excel 98 for Macintosh
This article was previously published under Q141766
SYMPTOMS
In Microsoft Excel, when you create a Microsoft Visual Basic for
Applications macro and you attempt to add an object for the second time,
the Add method fails and you receive the following error message:
Run time error 1004: Add method of <collection> class failed
Where <collection> is the object collection used.
CAUSE
This error message occurs when the collection object of the same class and
name already exists, and you attempt to add it a second time with the same
name.
This behavior is by design of Microsoft Excel, because it eliminates the
possibility of having two objects of the same class with the same name.
REFERENCES
For more information about getting help with Visual Basic for Applications,
please see the following article in the Microsoft Knowledge Base:
163435
VBA: Programming Resources for Visual Basic for
Applications
Additional query words: XL
Keywords: kbdtacode kberrmsg kbprb kbprogramming KB141766