I have a vb.net app that opens an excel worksheet, reads data and then closes
the sheet. Im noticing that the Excel process is still running after I have
closed and disposed of my excel objects.
The following code (Test1) demonstrates the essence of what I am doing.
When I check the processes while ruinning the method, I notice that the Excel
process remains after exiting the sub (and until I exit the application)
Sub Test1
Dim objExcelApp As New Excel.Applicati on
Dim objExcelWorkBoo k As Excel.Workbook =
objExcelApp.Wor kbooks.Open("C: \Test.xls")
Dim objExcelWorkshe et As Excel.Worksheet = objExcelWorkBoo k.Sheets(1)
Dim objRange As Excel.Range
objRange = objExcelWorkshe et.Range("A1")
MsgBox(objRange .Text)
''http://www.vbforums.co m/archive/index.php/t-396405.html
objRange = Nothing
objExcelWorkshe et = Nothing
objExcelWorkBoo k.Close()
objExcelWorkBoo k = Nothing
objExcelApp.Wor kbooks.Close()
objExcelApp.Qui t()
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
objExcelApp = Nothing
End Sub
When I strip the code dow to this (Test2) I notice that the process is
created on line
Dim objExcelApp As New Excel.Applicati on
and killed on line
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
Sub Test2
Dim objExcelApp As New Excel.Applicati on
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
objExcelApp = Nothing
End Sub
What is it that is keeping a reference to the Excel process and how do I
kill the process?
the sheet. Im noticing that the Excel process is still running after I have
closed and disposed of my excel objects.
The following code (Test1) demonstrates the essence of what I am doing.
When I check the processes while ruinning the method, I notice that the Excel
process remains after exiting the sub (and until I exit the application)
Sub Test1
Dim objExcelApp As New Excel.Applicati on
Dim objExcelWorkBoo k As Excel.Workbook =
objExcelApp.Wor kbooks.Open("C: \Test.xls")
Dim objExcelWorkshe et As Excel.Worksheet = objExcelWorkBoo k.Sheets(1)
Dim objRange As Excel.Range
objRange = objExcelWorkshe et.Range("A1")
MsgBox(objRange .Text)
''http://www.vbforums.co m/archive/index.php/t-396405.html
objRange = Nothing
objExcelWorkshe et = Nothing
objExcelWorkBoo k.Close()
objExcelWorkBoo k = Nothing
objExcelApp.Wor kbooks.Close()
objExcelApp.Qui t()
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
objExcelApp = Nothing
End Sub
When I strip the code dow to this (Test2) I notice that the process is
created on line
Dim objExcelApp As New Excel.Applicati on
and killed on line
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
Sub Test2
Dim objExcelApp As New Excel.Applicati on
System.Runtime. InteropServices .Marshal.Releas eComObject(objE xcelApp)
objExcelApp = Nothing
End Sub
What is it that is keeping a reference to the Excel process and how do I
kill the process?
Comment