I'm using VB to create Excel templates and everything appeared to be working fine until I was stepping though some code today with my Task Manager open. I noticed that I had numerous instances of Excel open that should not be. This is the code that is being called to close the process:
vb Code:
Public Sub Close() Try If Not oExcel Is Nothing Then oExcel.DisplayAlerts = False oExcel.Quit() oExcel = Nothing GC.Collect() End If Catch ex As Exception MessageBox.Show("TemplateReader.Close: " & ex.Message.ToString) End Try End Sub
When stepping through this code I am hitting the exception after the execution of the GC but the message box does not appear so the the using thinks that everything is fine.
When I close my applicataion all of the Excel processes shown by the Task Manager close as well. Can anyone help provide an explanation as to why the Excel instances do not close until the application closes?




Reply With Quote