Show Contents / Index / Search

Reference Macros in Other Documents

To access a macro in another session document or VBA project, you can reference that document or project in the Visual Basic Editor. The advantage of a reference is that you can maintain a single copy of your macros in a centrally located project. If you make changes to a macro, all projects that reference it get the updated version. Changes you make to your referenced project have no effect on session documents that reference your project or to the macros they contain.

Referencing a document or project uses the same process as adding an object library reference.

To reference a document or project

  1. From the Visual Basic Editor, select Tools > References.
  2. From the Reference dialog box, find the opened project in the list box, select the check box for the referenced project, and then click OK.
  3. Save your VBA project.

    Note: To remove a reference, clear the check box for the referenced project in the Reference dialog box.