Language AdditionsSeveral additions were made to the VBA language itself. ActiveX controls can now be sited on documents as well as forms. They are exposed as objects to the developer and can have code behind them. The event model is much richer than what was previously available with multiple events per object. An object that raises events is called an event source. To handle the events raised by an event source, you can declare a variable of the object's class using the new WithEvents keyword. For example, to handle Excel application events, place the following code in the Declarations section of a class module. |
Private WithEvents mApp As Application Private Sub mApp_WorkbookBeforeClose(ByVal Wb As Excel.Workbook, Cancel As Boolean) MessageBox "Workbook about to close!" End Sub
The events currently on Excel's application class include:
As you can see the event model has gotten much richer for the developer with the number of events that can be handled increasing. Optional arguments in the past had to be typed as a variant. In VBA 5.0 this restriction has been removed allowing optional arguments to be strongly typed if desired. In addition optional arguments can now be used with Property Let and Property Get. |
Don't use a big word where a diminutive one will suffice. |
Copyright© 1996-1999, Baarns Consulting Group, Inc. - All rights reserved. |