Scripting Excel - EXCEL.EXE refuses to leave task manager after .Quit and =Nothing?

M

Matt

I've done extensive searches on the web and newsgroups trying to
resolve this problem, and I've had no luck. I've seen and tried many
suggestions, and none have worked.

I'm trying to create an Excel object using VB within IE (I've also
tried javascript with forced garbage collection with no luck).

THE PROBLEM: After closing Excel, the EXCEL.EXE task hangs around in
the task manager forever, until I kill it. Since I'll be generating
multiple excel instances, this will be unacceptable. I need to figure
out how to actually close excel correctly.

Here is a test case:
http://www.mattkruse.com/temp/excel_automation.html
(obviously, to run the test case, you need to allow activeX and
scripting)

When running this, the first option works correctly - it creates the
object, closes it, and EXCEL.EXE goes away. But when a workbook is
opened in the second test, EXCEL.EXE fails to go away.

I am using Excel 2000 and Windows XP, if that makes any difference.

Can anyone suggest things to try to force EXCEL.EXE to close?
Or even better, modify the code in my example test case so that it
works correctly?

Thanks!

Matt Kruse
http://www.mattkruse.com/
 
M

Matt

The example URL has all the source, but here it is also:

Function generateExcel(openDoc)
Dim excel

msgbox("Ready to create Excel.Application")
Set excel = CreateObject("Excel.Application")
msgbox("Excel.Application created - you should now see EXCEL.EXE in
your task manager")

if (openDoc) then
msgbox("Ready to open XLS file")
excel.Workbooks.Open("http://www.mattkruse.com/temp/test.xls")
msgbox("Workbook opened")

msgbox("Ready to close workbook")
excel.Workbooks.Item(1).Close
msgbox("Workbook closed")
end if

msgbox("Ready to Quit Excel")
excel.Quit
msgbox("Excel quit")

msgbox("Ready to set excel object to Nothing")
Set excel = Nothing
msgbox("Set to nothing")

msgbox("EXCEL.EXE should now disappear from task manager - but if the
workbook was opened, it doesn't!")

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top