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

Before the procedures will run, however, you must connect the declared object in the class module with the Document 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.Doc = ThisDrawing
    End Sub
  3. In the code for your main module, add a call to the InitializeApp subroutine:
    Call InitializeEvents

    Once the InitializeEvents procedure has been run, the Doc object in the class module points to the Document object created, and any event procedures in the class module will run when the events occur.