Figure Applicationlevel events

Public tfithEuente App hs Appli Private Sub Workbook(Byl

End Sub

Private Sub App_SheetftCliuste( HsgBcx "AppLicatian~lau*l Shee End Sub

StmtfieforBDc jt 1st li:k iHeelSefoieFf-iiMJiick lihluelCalijLlBlid fnhHftirhanqR

3hBelDeadi«tB ShtelSeltdionC I ai




2. In the code module in which you want to activate Application-level events (say, the code module associated with a workbook, worksheet, or chart), place the following declaration in the declarations section of the module:

Tea1H ly®

Dim AppObj As New CApp

(You can use any variable name you wish in place of AppObj ).

3. Finally, assign the App property of AppObj to the Application object, by executing the code:

Set AppObj.App = Excel.Application

It is up to you where to place this line of code, but it must be executed in order to activate Application-level events. (There is a certain circularity here, since a natural place to put this code is in the WorkbookOpen event. However, this event will not fire until this code has been executed.)

In addition to using the EnableEvents property, you can turn off Application-level events by executing the code:

Set AppObj.App = Nothing

0 0

Post a comment