Close an app in C#

  • Thread starter Thread starter Richie
  • Start date Start date
R

Richie

Hi all,

I want to close excel application from C#, this is the piece of code I am
trying

"System.Runtime.InteropServices.Marshal.ReleaseComObject(excelApp);"

GC.Collect();

It ain't working ! Any ideas please !!

Thanks.
 
Assuming that your variable excelApp is just a reference to an Excel
Application, all you have to do is call excelApp.Quit();

HTH, Jakob.
 
Hi Richie,

This is fine, but on viewing "Task List" the application tab shows
"Excel.exe" running. And if I run the program again the message
"Administrator is using the file, file will open in readonly mode" shows.

Any ideas ?
 
It sounds like you may be holding a reference to some of the Excel COM
objects. Did you try calling ReleaseComObject until it returns 0 on all your
references before calling Quit()?
 
Back
Top