Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel object event handling

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default excel object event handling

The answer is the
Microsoft Knowledge Base Article - 316653
(http://support.microsoft.com/default.aspx?kbid=316653)


"Vladimir Kryachko" wrote in
message ...
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




Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
perform an event if mouse rolled over an object [email protected] Excel Worksheet Functions 0 September 5th 06 08:28 PM
checkbox event handling function nevwalters Excel Worksheet Functions 2 May 16th 06 04:27 AM
Object vs Picture Handling in Different Versions of Excel Rif Excel Discussion (Misc queries) 0 October 9th 05 08:43 AM
Excel Error Handling brutalmetal Excel Programming 1 January 13th 04 02:11 PM
OLE Excel data handling from VB Faiz[_2_] Excel Programming 2 July 11th 03 02:32 PM


All times are GMT +1. The time now is 10:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"