i'm trying to clean up after using an Excel.Application from my Access programme. i can do this no problem if i'm using early binding however if i'm using late binding i can't seem to close it.
the problem come in after the sort in Excel 2007.
here's my code below and here's the sample database.
Question: how come early binding successfully closes the Excel instance in task manager but late binding doesn't?
Option Compare Database
'dear Experts Exchange experts, kindly try to change the compiler constant between "Late" and "Early2007"
#Const ExcelBindingAndVersion = "Late" '"Early2003" or "Early2007" or "Late"
#If ExcelBindingAndVersion = "Early2003" Or ExcelBindingAndVersion = "Early2007" Then
'early binding for 2003 and 2007
Dim xlsApp As Excel.Application
Dim xlsWbk As Excel.Workbook
Dim xlsWst As Excel.Worksheet
Set xlsApp = New Excel.Application
#ElseIf ExcelBindingAndVersion = "Late" Then
Dim xlsApp As Object 'excel object
Dim xlsWbk As Object 'excel object
Dim xlsWst As Object 'excel object
Set xlsApp = VBA.CreateObject("Excel.Application")
Set xlsWbk = xlsApp.Workbooks.Add
Set xlsWst = xlsWbk.Worksheets(1)
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
Set xlsWst = Nothing
Set xlsWbk = Nothing
Set xlsApp = Nothing
'at this point in time, if i used early binding and i open task manager, there will be NO excel processes running
'however if i use late binding i'll still have an excel process running.
'this Excel process "unwilling to die" only happens after running the sort code