This should be a fairly common scenario, but I haven't yet found a solution
on google.
(On WinXP Pro SP2 / Access 2003 / Excel 2003)
The following code, when run from Access, leaves a copy of Excel.exe hanging
around.
'***********************************************
Sub testXL()
Dim objXL As Object
Dim wkbXL As Object
Dim strFileName As String
On Error GoTo errHandler
strFileName = "C:\Test.xls"
Set objXL = CreateObject("Excel.Application")
Set wkbXL = objXL.Workbooks.Open(strFileName)
exitHere:
On Error Resume Next
wkbXL.saved = True
wkbXL.Close
' also tried this
' wkbXL.Close savechanges:=False
Set wkbXL = Nothing
objXL.Quit
Set objXL = Nothing
On Error GoTo 0
Exit Sub
errHandler:
MsgBox (Err.Description)
Resume exitHere
End Sub
'***********************************************
Early binding seems to make no difference. Any ideas on how to release Excel
from memory would be appreciated.