Article ID: 266088 - Last Review: May 15, 2007 - Revision: 5.2 BUG: Excel Does Not Shut Down After Calling the Quit Method When Automating from JScriptThis article was previously published under Q266088 On This PageSYMPTOMS When automating Microsoft Excel from Microsoft JScript,
Excel stays in memory after calling the Quit method until you close Internet Explorer or navigate to another
page. CAUSE JScript is holding on to a reference to Excel. Because
there is a reference on Excel when you issue the Quit command, Excel does not shut down. JScript is a garbage
collecting language, which means the engine cleans up after itself at a certain
point, and not when you set the variables to NULL. When you shut down Internet Explorer or move to another page,
the engine is destroyed. This behavior forces garbage collection and frees the
reference to Excel. RESOLUTION To work around this problem, you can call the CollectGarbage method. This forces JScript's garbage collection to occur
immediately, which releases the reference to Excel. The following code snippet
illustrates how to use the CollectGarbage method: Another workaround to this problem is to use VBScript for Automation of Microsoft Excel. Unlike JScript, VBScript is not a garbage collecting language and, therefore, references are released when you set the variables to Nothing. Using VBScript, Excel shuts down immediately after calling the Quit method and releasing the variables. Please see the "References" section of this article for more information. NOTE: The undocumented CollectGarbage method is not part of the ECMA-262 specification, and may not be available in future versions of the scripting engine. When you force the garbage collector to run by calling CollectGarbage, this may also negatively impact performance. STATUSMicrosoft has confirmed that this is a bug in the Microsoft
products that are listed at the beginning of this article.
MORE INFORMATIONSteps to Reproduce Behavior
REFERENCESFor
additional information a VBScript code sample that demonstrates Automation to
Excel, click the article number below to view the article in the Microsoft
Knowledge Base: 198703
(http://support.microsoft.com/kb/198703/EN-US/
)
HOWTO: Automating Excel From Client-Side VBScript
For more information on Office Automation, please
visit the Microsoft Office Development support site at: http://support.microsoft.com/ofd
(http://support.microsoft.com/ofd)
APPLIES TO
| Article Translations
|
Back to the top
