excel object event handling
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.interop.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Vladimir Kryachko (VIP)
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

What do I wrong?

Thanx

Reply to this message...
 
    
Vladimir Kryachko
The answer is there:
Microsoft Knowledge Base Article - 316653
(http://support.microsoft.com/default.aspx?kbid=316653)

"Vladimir Kryachko" <Vladimir Click here to reveal e-mail address> wrote in
message news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 
System.InvalidCastException




Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
 
 Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us - Terms of Use - Privacy Policy - www.dotnet247.com