Y
Yi
I have a COM addin for Excel written in VB.NET. In this addin, I added event
handling method for the Excel.Application object. I noticed that one Excel
process stays in the memory after I double-clicking on an Excel Worksheet
object (and then cause it to lose focus by clicking on other area of the Word
document and then close the document) that is inserted in a Word document via
Word menu "Insert/Object ->Microsoft Excel Worksheet".
The following is my testing code.
------------------------------------------------------
Private WithEvents m_Excel As Excel.Application
Public Sub OnDisconnection(ByVal RemoveMode As ...) Implements ...
System.Runtime.InteropServices.Marshal.ReleaseComObject(m_Excel)
m_Excel = Nothing
End Sub
Public Sub OnConnection(ByVal application As Object, ...) Implements ...
m_Excel = CType(application, Excel.Application)
End Sub
Private Sub m_Excel_WorkbookOpen(ByVal Wb As
Microsoft.Office.Interop.Excel.Workbook) Handles m_excel.WorkbookOpen
End Sub
------------------------------------------------------
Notice that if I remove the method "m_Excel_WorkbookOpen", the above
operation will not leave a hanging Excel process. So, I guess the use of
Event handling in this code caused the problem. Is there a solution to this
issue?
Many thanks.
handling method for the Excel.Application object. I noticed that one Excel
process stays in the memory after I double-clicking on an Excel Worksheet
object (and then cause it to lose focus by clicking on other area of the Word
document and then close the document) that is inserted in a Word document via
Word menu "Insert/Object ->Microsoft Excel Worksheet".
The following is my testing code.
------------------------------------------------------
Private WithEvents m_Excel As Excel.Application
Public Sub OnDisconnection(ByVal RemoveMode As ...) Implements ...
System.Runtime.InteropServices.Marshal.ReleaseComObject(m_Excel)
m_Excel = Nothing
End Sub
Public Sub OnConnection(ByVal application As Object, ...) Implements ...
m_Excel = CType(application, Excel.Application)
End Sub
Private Sub m_Excel_WorkbookOpen(ByVal Wb As
Microsoft.Office.Interop.Excel.Workbook) Handles m_excel.WorkbookOpen
End Sub
------------------------------------------------------
Notice that if I remove the method "m_Excel_WorkbookOpen", the above
operation will not leave a hanging Excel process. So, I guess the use of
Event handling in this code caused the problem. Is there a solution to this
issue?
Many thanks.