
Accessing VBIDE.VBE.VBProjects via Excel in VB .NET Causes Excel To Crash When Closed
Here is an interesting one. Create a console project and reference
Excel and VBIDE. Add the following code:
Public Sub Main()
'**** Dimension Local Variables ****
Dim XL As New Excel.Application()
Dim VBProject As VBIDE.VBProject
'**** Access VB Projects ****
For Each VBProject In XL.VBE.VBProjects
Next VBProject
'**** Close Excel Application ****
XL.Quit()
XL = Nothing
End Sub
When the application terminates and the garbage collection is called,
the Excel application crashes and returns:
OleMainThreadWndName: excel.exe - Application Error
The instruction at "0x77b26033" referenced memory at "0x01144a94".
The
memory could not be read.
I'm running NT and Excel 98. To work around I'm currently calling a
VB6 .dll that performs the required task (stripping VBProjects from an
Excel workbook) but that is a less than perfect solution.
Any ideas anyone?