To Create a New Class and Declare a Circle Object with Events (VBA/ActiveX)

You can declare a variable for a specific object type using the WithEvents keyword to get notified when an event is executed.

  1. In the VBA IDE, insert a class module. From the Insert menu, choose Class Module.
  2. Select the new class module in the Project Explorer window.
  3. Change the name of the class in the Properties window to EventClass-Module.
  4. Open the Code window for the class using F7, or by selecting the menu option View Code.
  5. In the Code window for the class, add the following line:
    Public WithEvents Object As AcadCircle

    After the new object has been declared with events, it appears in the Object drop-down list box in the class module, and you can write event procedures for the new object in the class module. (When you select the new object in the Object box, the valid events for that object are listed in the Procedure drop-down list box.)