Hi there,
I´m using Excel automation with C#. When closing Excel, the Excel.exe process still remains in the Task Manager. I´ve tried all the topics that can be found, but Excel won´t quit. When I make Excel visible and close it myself, then the process will stop. But when I call the Quit() method, it keeps running.
Here is my code:
Excel.Application oExcel = new Excel.Application(); oExcel.Visible = true; Excel.Workbooks oWorkbooks = oExcel.Workbooks; string Pfad = "C:\test.xlsx"; Excel.Workbook oWorkbook = oWorkbooks.Open(Pfad); Excel.Worksheet oSheet = oWorkbook.Sheets[1]; oSheet.Cells[1, 1] = "Test"; oSheet.SaveAs("C:\test.xlsx"); GC.Collect(); GC.WaitForPendingFinalizers(); Marshal.FinalReleaseComObject(oSheet); oWorkbook.Close(); Marshal.FinalReleaseComObject(oWorkbook); oExcel.Workbooks.Close(); Marshal.FinalReleaseComObject(oWorkbooks); oExcel.Application.Quit(); Marshal.FinalReleaseComObject(oExcel); oExcel = null;
Thanks for any help!