Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

excel.exe still in task manager

2 views
Skip to first unread message

booner

unread,
Jan 17, 2008, 11:34:31 AM1/17/08
to
I have a vb.net app (.net 2.0 framework) on an xp machine with Office 2003
installed. My app needs to generate an export of data into a spreadsheet
(various flavors of excel).

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


Tosco

unread,
Jan 22, 2008, 12:19:18 AM1/22/08
to
Have you tried using the ReleaseComObject before setting the pointers
to null?

Stefano

booner

unread,
Jan 23, 2008, 2:42:16 PM1/23/08
to
I have ... and didn't see any difference.


"Tosco" <stefan...@gmail.com> wrote in message
news:e10ff6d9-84d5-4611...@e6g2000prf.googlegroups.com...

0 new messages