I am having problem closing Excel in C#

Jul 29 2010 4:15 PM
I don't know what is wrong but Excel.exe remains in the task list even after I have entered this source code:

  ExcelWorkBook.SaveAs(Directory.GetCurrentDirectory() + "\\deleteme.xls", misValue, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlNoChange, misValue, misValue, misValue, misValue);
            ExcelWorkBook.Close(null, null, null);
            ExcelApplication.Quit();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkBooks);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkSheet);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelWorkBook);
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ExcelApplication);
         
            GC.Collect();
            GC.WaitForPendingFinalizers();

I  cannot seem to close Excel in C#. Any help would be greatly appreciate it! Thanks in advance.

Answers (7)