I am running:
Win XP SP2
Excel 2002, Access 2002 (Office XP SP3)
Using Visual Basic (not VB.NET)
At one point (prior to XP SP2?!? - I can't pin it down), this did
not happen and I was easily able to destroy instances of excel (with
the exact same code). I have read many, many posts, and they seem to
get bogged down in specifics. So I cribbed this program from the
automation help file, simplified it further, so hopefully someone can
steer me to the root causes of this.
Two versions of code, one that works just fine, and the other that
leaves a hanging instance of excel that can only be removed by ending
the EXCEL.EXE process from the task manager.
Sub WorksFine()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
' It Seems to be the process of opening a workbook
' that is causing the problems
' -this also happens with
' xlbook = xlApp.Workbooks.Open("C:\Book1.xls))
'
' Set xlBook = xlApp.Workbooks.Add()
' xlBook.Worksheets(1).Cells(1, 1).Value = "Hello"
' xlBook.SaveAs "C:\Book1.xls"
' xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
This next sub leaves an instance of excel hanging in the background.
This instance can be made visible by typing
"Excel.Application.Visible=True" in the immediate window.
However, "Excel.Application.Quit" in the immediate windown merely
returns it to its invisible status- does not remove EXCEL.EXE from the
list of processes.
Sub WhatTheHeck()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlBook = xlApp.Workbooks.Add()
xlBook.Worksheets(1).Cells(1, 1).Value = "Hello"
xlBook.SaveAs "C:\Book1.xls"
xlBook.Close
Set xlBook = Nothing
xlApp.Quit
Set xlApp = Nothing
End Sub
I have come across many suggestions, but none seem to be applicable.
The symptoms are described in several kb articles.
This one describes the symptoms quite well:
XL2000: Automation Doesn't Release Excel Object from Memory
http://support.microsoft.com/default...b;en-us;199219
Thanks for any help!
Taylor