B
Bill
I have inherited an App desigend by an ex employee
Sometimes the program leaves Excel in the task manager
The programe uses various routines and calling various functions that define
Excel sheets etc (badly named)
I'm finding it hard to follow (my 1st experince of .NET)
is there a way to KILL any Excel instence when exiting the program.
I have come across some posts about GC (garbage collection)
like this
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWsheet)
oXLWsheet = Nothing
'System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWs)
oXLWs = Nothing
oBook.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
-----
My problem is I don't know ALL the Sheets & Books etc that have been defined
/used
program loops about a lot
It would be nice just to do someting like
Loop Until NoMore
GetProcessByName("EXCEL")
Kill Process
END
Sometimes the program leaves Excel in the task manager
The programe uses various routines and calling various functions that define
Excel sheets etc (badly named)
I'm finding it hard to follow (my 1st experince of .NET)
is there a way to KILL any Excel instence when exiting the program.
I have come across some posts about GC (garbage collection)
like this
System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWsheet)
oXLWsheet = Nothing
'System.Runtime.InteropServices.Marshal.ReleaseComObject(oXLWs)
oXLWs = Nothing
oBook.Close()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBook)
oBook = Nothing
System.Runtime.InteropServices.Marshal.ReleaseComObject(oBooks)
oBooks = Nothing
oExcel.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(oExcel)
oExcel = Nothing
GC.Collect()
GC.WaitForPendingFinalizers()
-----
My problem is I don't know ALL the Sheets & Books etc that have been defined
/used
program loops about a lot
It would be nice just to do someting like
Loop Until NoMore
GetProcessByName("EXCEL")
Kill Process
END