Article ID: 178510 - Last Review: May 14, 2007 - Revision: 6.3 Excel automation fails second time code runsThis article was previously published under Q178510 On This PageSYMPTOMS While running code that uses Automation to control
Microsoft Excel, one of the following errors may occur: In Microsoft Excel 97 and in later versions of Excel, you receive one of the following error message: Error message 1
Run-time error '1004': Method '<name of method>' of object '_Global' failed Error message 2 Application-defined or
object-defined error Error message 1 Run-time error '-2147023174' OLE Automation error Error message 2 Run-time error '462': The remote server machine does not exist or is unavailable. CAUSE Visual Basic has established a reference to Excel because of a
line of code that calls an Excel object, method, or property without qualifying
the element 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 one time. RESOLUTION To resolve this problem, modify the code so each call to an Excel object,
method, or property is qualified with the appropriate object variable.
STATUS
This behavior is by design. MORE INFORMATION To automate Microsoft Excel, you establish an object
variable that usually refers to the Excel Application object or the Excel Workbook object. Other
object variables can then be set to refer to a Worksheet, a Range, or other
objects in the Microsoft Excel object model. When you write code to use an
Excel object, method, or property, you should always precede the call with the
appropriate object variable. If you do not, Visual Basic establishes its own
reference to Excel. This reference might cause problems when you try to run the
automation code multiple times. Note that even if the line of code begins with
the object variable, a call may be made to an Excel object, method, or
property in the middle of the line of code that is not preceded with an object
variable. The following steps illustrate how to reproduce this issue and how to correct the issue. Steps to reproduce the behavior
REFERENCES
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
167223
(http://support.microsoft.com/kb/167223/
)
Microsoft Office 97 Automation Help file available
189618
(http://support.microsoft.com/kb/189618/
)
You may receive the "Run-time error '-2147023174' (800706ba)" error message or the "Run-time error '462'" when you run Visual Basic code that uses Automation to control Word
APPLIES TO
| Article Translations
|
Back to the top
