V
Vladimir Kryachko
Hello,
I need to handle an Excel.Workbook.BeforeClose event in my VB.NET
application. When the framework attempts to bind the event with my handler,
it throws a System.InvalidCastException with message "No such interface
supported".
I included the relevant declarations:
Imports Excel
....
Public Class TimeReportSheet
....
Private WithEvents excelWorkBook As Workbook
....
Public Sub Form(...
Dim excelApp As Excel.Application = Nothing
excelApp = New Excel.Application()
...
excelWorkBook = excelApp.Workbooks.Add() ' the exception is thrown here
...
End Sub
Private Sub Workbook_BeforeCloseEventHandler(ByRef Cancel As Boolean)
Handles excelWorkBook.BeforeClose
Cancel = False
End Sub
....
End Class
-------------
I have Microsoft Development Environment 2002 version 7.0.9466, Microsoft
..NET Framework 1.0 version 1.0.3705, Microsoft Excel 11.0 Object Library, MS
Office 2003
What do I wrong?
Thanx
I need to handle an Excel.Workbook.BeforeClose event in my VB.NET
application. When the framework attempts to bind the event with my handler,
it throws a System.InvalidCastException with message "No such interface
supported".
I included the relevant declarations:
Imports Excel
....
Public Class TimeReportSheet
....
Private WithEvents excelWorkBook As Workbook
....
Public Sub Form(...
Dim excelApp As Excel.Application = Nothing
excelApp = New Excel.Application()
...
excelWorkBook = excelApp.Workbooks.Add() ' the exception is thrown here
...
End Sub
Private Sub Workbook_BeforeCloseEventHandler(ByRef Cancel As Boolean)
Handles excelWorkBook.BeforeClose
Cancel = False
End Sub
....
End Class
-------------
I have Microsoft Development Environment 2002 version 7.0.9466, Microsoft
..NET Framework 1.0 version 1.0.3705, Microsoft Excel 11.0 Object Library, MS
Office 2003
What do I wrong?
Thanx