Excel automation fails second time code runs (178510)
The information in this article applies to:
- Microsoft Excel 2000
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 4.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 4.0
- Microsoft Visual Basic Standard Edition for Windows 4.0
- Microsoft Visual Basic for Applications 5.0
- Microsoft Office XP Developer
- Microsoft Office 2000 Developer
- Microsoft Excel 2002
- Microsoft Excel 97 for Windows
- Microsoft Excel for Windows 95
- Microsoft Excel for Windows 95 7.0a
This article was previously published under Q178510 SYMPTOMS While running code that uses Automation to control
Microsoft Excel, one of the following errors may occur: With
Microsoft Excel 97 and later, you receive the error:
Run-time error '1004': Method '<name of method>' of object '_Global'
failed -or- Application-defined or
object-defined error With Microsoft Excel 95, you receive the error:
Run-time error '-2147023174' OLE Automation error
-or- Run-time error '462': The remote
server machine does not exist or is unavailable. CAUSE Visual Basic has established a reference to Excel due to a
line of code that calls an Excel object, method, or property without qualifying
it with an Excel object variable. Visual Basic does not release this reference
until you end the program. This errant reference interferes with automation
code when the code is run more than once. RESOLUTION Modify the code so that each call to an Excel object,
method, or property is qualified with the appropriate object variable.
STATUS This behavior is by design. REFERENCES For additional information, please see the following
articles in the Microsoft Knowledge Base: 167223
Microsoft Office 97 Automation Help File Available on MSL
189618 PRB: Automation Error Calling Unqualified Method or Property
Modification Type: | Minor | Last Reviewed: | 8/18/2005 |
---|
Keywords: | kbAutomation kbtshoot kbprb KB178510 |
---|
|