I have the following code:
Dim excel, activesheet, workbook As Object
excel = CreateObject("Excel.Application")
excel.Visible = False
excel.ScreenUpdating = False
excel.Application.DisplayAlerts = False
excel.Interactive = False
workbook = excel.Workbooks.Open(exportFile)
activesheet = excel.ActiveSheet
Dim row As Integer = 3
For each item in dataset
activesheet.Range("A" & row).Value "item A"
activesheet.Range("B" & row).Value "item B"
.
.
.
activesheet.Range("CB" & row).Value "item CB"
row =+= 1
Application.DoEvents()
Next
workbook.Save()
workbook.Close()
excel.Quit()
activesheet = Nothing
workbook = Nothing
excel = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(activesheet)
System.Runtime.InteropServices.Marshal.ReleaseComObject(workbook)
System.Runtime.InteropServices.Marshal.ReleaseComObject(excel)
GC.Collect()
GC.WaitForPendingFinalizers()
Code works great - excel file gets updated - but long after this code is
run - excel.exe is still in my task manager and if I attempt to launch this
file - it does not work. If I manually kill the excel.exe process OR close
my app, the excel file is good to go.
What do I need to do to cleanup and ensure excel.exe closes appropriately?
I've seen references to killing the excel.exe process - but that seems a bit
of a workaround - would prefer to do this elegantly.
I've tried that as well - and same results.
Many thanks for any/all pointers or assistance.
BBB
Stefano
"Tosco" <stefan...@gmail.com> wrote in message
news:e10ff6d9-84d5-4611...@e6g2000prf.googlegroups.com...