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()?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Close an excel app in C# 5
calling gc.collect 1
closing excel from c# 6
cominterop excel and c# 4
excel reference remains open 3
C# Excel 2
How to stop the excel process created in my code 1
Handle COM events 5

Back
Top