T
Terry Holland
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.Application
Dim objExcelWorkBook As Excel.Workbook =
objExcelApp.Workbooks.Open("C:\Test.xls")
Dim objExcelWorksheet As Excel.Worksheet = objExcelWorkBook.Sheets(1)
Dim objRange As Excel.Range
objRange = objExcelWorksheet.Range("A1")
MsgBox(objRange.Text)
''http://www.vbforums.com/archive/index.php/t-396405.html
objRange = Nothing
objExcelWorksheet = Nothing
objExcelWorkBook.Close()
objExcelWorkBook = Nothing
objExcelApp.Workbooks.Close()
objExcelApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
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.Application
and killed on line
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
Sub Test2
Dim objExcelApp As New Excel.Application
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
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.Application
Dim objExcelWorkBook As Excel.Workbook =
objExcelApp.Workbooks.Open("C:\Test.xls")
Dim objExcelWorksheet As Excel.Worksheet = objExcelWorkBook.Sheets(1)
Dim objRange As Excel.Range
objRange = objExcelWorksheet.Range("A1")
MsgBox(objRange.Text)
''http://www.vbforums.com/archive/index.php/t-396405.html
objRange = Nothing
objExcelWorksheet = Nothing
objExcelWorkBook.Close()
objExcelWorkBook = Nothing
objExcelApp.Workbooks.Close()
objExcelApp.Quit()
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
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.Application
and killed on line
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
Sub Test2
Dim objExcelApp As New Excel.Application
System.Runtime.InteropServices.Marshal.ReleaseComObject(objExcelApp)
objExcelApp = Nothing
End Sub
What is it that is keeping a reference to the Excel process and how do I
kill the process?