To Connect the Declared Object to the Application Object (VBA/ActiveX)

Before a procedure related to the event of an object is executed, you must connect the declared object in the class module with the Application object.

  1. In the Code window for your main module, add the following line to the declarations section:
    Dim X As New EventClassModule
  2. In the same window, add the following subroutine:
    Sub InitializeEvents()
      Set X.App = ThisDrawing.Application
    End Sub
  3. In the code for your main module, add a call to the InitializeEvents subroutine:
    Call InitializeEvents

    Once the InitializeEvents procedure has been run, the App object in the class module points to the Application object specified, and any event procedures in the class module will run when the events occur.