Reference Other VBA Projects
 
 
 

Referencing one VBA project from another allows developers to share code more easily. Developers can create libraries of commonly used macros and then reference the library when needed. This keeps the shared code centrally located and supported, while allowing a large number of developers to utilize the code.

Once another project has been successfully referenced, you will notice a new folder in the Projects window of the VBA IDE. This new folder is titled References and contains the name of the project referenced.

Once you have referenced a project, you can use any public code or form component in that project.

When a project that references another project is loaded into AutoCAD, the referenced project is automatically loaded into AutoCAD as well. The referenced project cannot be closed until all projects that reference it are closed first.

You cannot make circular references. That is, you cannot reference a project that contains a reference back to the first project. If you accidentally create a circular reference, you will be notified by VBA.

Project referencing is a standard feature of Microsoft VBA. There is no additional work in AutoCAD to extend this functionality. You can find more information on referencing projects in the Microsoft VBA Help. You can open the Microsoft VBA Help from the Help menu in the VBA IDE.

NoteYou cannot reference embedded projects or VBA projects from other applications.

To reference another VBA project

  1. In the Project window of the VBA IDE, select the project to which you will be adding the reference.
  2. From the Tools menu, select the References option to open the References dialog box.
  3. From the References dialog box, press the Browse button to open the Add Reference dialog box.
  4. From the Add Reference dialog box, select the project file you want to reference and then press the Open button.
  5. From the Add Reference dialog box, select the OK button to complete the reference addition.