Re: How to close excel object with C#

M

Mary Chipman

You need to use the ReleaseComObject method on each and every call. My
understanding of the issue is that Excel opens up a lot of additional
objects under the covers which don't get released. If this isn't
working, look to see what //do some stuff is actually doing and if
this is the problem. You don't want to use GC.Collect -- that forces
collection for all processes. I'm not 100% sure, but I believe it has
no effect on unmanaged code.

--mary
 
Joined
Nov 9, 2010
Messages
1
Reaction score
0
This is an easy way to do it

Simply call the "Quit()" function of the relevant Excel.Application object. For example...

Code:
using Excel = Microsoft.Office.Interop.Excel; 

//this is required because there is otherwise an ambiguity between the Application" class under the Windows.Forms namespace and that of Excel 
//if not you can simply say...

using Microsoft.Office.Interop.Excel;


//Then within your class you create an instance of the Excel.Application class

Excel.Application excel_app = new Excel.Application();

//Do whatever you want
.
.
.
.
.

excel_app.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

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top