View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Francesco Geri Francesco Geri is offline
external usenet poster
 
Posts: 8
Default Closing die hard process EXCEL.EXE

Thanks Simon,

I have added an explicit call to GC.Collect.
In this way my VB.NET program works well, but the same code in an ASP.NET
application doesen't work...
Unfortunately my final application must be an ASP.NET application...
The EXCEL process keeps alive after the applicatoin ends, and also if I kill
asp_net process or restart iis the process keeps alive...

Do you know if I can read the PID of Excel.Application object? If yes I can
kill the process... It's a bad idea, I know, but....

Franx


"Simon Murphy" ha scritto nel messaggio
...
franx
try forcing garbage collection

excelApp = nothing
GC.Collect()
GC.WaitForPendingFinalizers()
GC.Collect()
GC.WaitForPendingFinalizers()

This works for me in C# the Vb code wont be far different.
as you say its a die hard process!

cheers
Simon
"Francesco Geri" wrote in message
...
Hi,
I have a VB.NET program that opens an EXCEL workbook. In this program I
modify the workbook, I save it, then I close it.
The code is like this:

Sub mySub()

Dim excelApp As Excel.Application
Dim excelDoc As Excel.Workbook

excelApp = New Excel.Application
excelDoc = excelApp.Workbooks.Open("c:\temp\test.xls")

'code that update the workbook....

excelDoc.Close(True)
excelDoc = Nothing

excelApp.Quit()
excelApp = Nothing

End Sub


I have no errors, but the EXCEL.EXE process keep alive after the
execution.

The EXCEL.EXE process starts on statement:

excelApp = New Excel.Application

and it should die on statement:

excelApp.Quit()


It's right?

Thanks for help!

franx