O'Reilly logo

Writing Word Macros, Second Edition by Steven Roman PhD

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Referencing a Project

For code in one project to call a public procedure in another project, the calling project must have a reference to the called project.

Generally, a project that is associated with a document is interested only in procedures that lie in that project, in the template that is attached to the document, or in the Normal template. (It would probably be bad programming practice to require a procedure in one document project to call a procedure in another document project.)

In the first case, no references need be set. The second case is taken care of by Word, since it automatically provides a reference to the attached template.

On the other hand, if the attached template is not the Normal template and you want to call a procedure in the Normal template, or if you want to call a procedure in another nonreferenced project, then you need to add a reference to the calling project. This is done using the References dialog box (under the Tools menu) shown in Figure 6-2.

The References dialog box

Figure 6-2. The References dialog box

It is important to note that if the template that is attached to a document is not the Normal template, then Word does not automatically provide a reference to the Normal project in the document project. This may seem a bit surprising, for although we can execute any macros that reside in the Normal template from within the document itself (using the Macros menu item, for ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required