• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 5. Program Excel with .NET >  Respond to Events in .NET Applications

5.14. Respond to Events in .NET Applications

The default Visual Studio .NET Excel project contains object declarations for the Excel Application and Workbook objects using the WithEvents clause. That, plus the initialization code in the _Startup procedure, enables event handling for those two objects.

   Public Class OfficeCodeBehind 

       Friend WithEvents ThisWorkbook As Excel.Workbook
       Friend WithEvents ThisApplication As Excel.Application

   #Region "Generated initialization code"
       ' Default constructor.
       Public Sub New(  )
       End Sub
   
       ' Required procedure. Do not modify.
       Public Sub _Startup(ByVal application As Object, _
         ByVal workbook As Object)
           ThisApplication = CType(application, Excel.Application)
           ThisWorkbook = CType(workbook, Excel.Workbook)
       End Sub
   ' Remaining class definition omitted here...


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint