SomeDeveloperPerson

I have an Windows Forms application that uses the Excel application to create a spreadsheet, saves it and then quits the excel application - all programmatically. The problem is that the Excel.exe process remains running in the background until the windows forms application is exited. I've tried the following:


Code Snippet

/**Do Garbage Collection as suggested as best practice at:
* http://msdn2.microsoft.com/en-us/library/aa679807(office.11).aspx
*/
excelWorkBooks = null;
mainbook = null;
sheet = null;
someRange = null;
/**Quit the application.*/
excelApplication.Quit();
excelApplication = null;
/**Collect Garbage (Twice).*/
GC.Collect();
GC.WaitForPendingFinalizers();
GC.Collect();
GC.WaitForPendingFinalizers();


and the following, passing the COM objects when done

Code Snippet

private void releaseCOMObject(object COMObject){
try {
if(COMObject != null)
while(System.Runtime.InteropServices.Marshal.ReleaseComObject(COMObject)>0);
}
finally {
COMObject = null;
}
}


These do not work.

What else can I try



Re: Visual Studio Tools for Office Excel.exe Process Running

VMazur

I move your post it to proper forum




Re: Visual Studio Tools for Office Excel.exe Process Running

Dennis Wallentin

Which has been answered here: http://forums.microsoft.com/MSDN/ShowPost.aspx PostID=1544073&SiteID=1




Re: Visual Studio Tools for Office Excel.exe Process Running

Cindy Meister

Hi Val

Just FYI, the VSTO forum is not the proper place for asking Office automation questions. It's for questions about the VSTO technology. Please direct people to an appropriate newsgroup, or move such questions to the "Where is the Forum for..." forum for redirection to an appropriate newsgroup.