Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

Custom Document Templates

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

One way to build an application in Microsoft® Word is to create a custom template on which a user bases new documents. The template that is attached to a document is specified in the Document template box in the Templates and Add-ins dialog box (Tools menu). A document can have only one document template. Even when a document template is attached to a document, however, the Normal template remains loaded.

You should create a custom document template when:

  • Your application requires that some boilerplate text or fields be included in the document when it is created.
  • You want to make custom styles available to each document the user creates.
  • Your application includes custom toolbars or menus the user can use while working with documents based on the template.
  • You want to call Microsoft® Visual Basic® for Applications (VBA) procedures in the template from code running in a document that is based on the template.

Custom document templates are good for ensuring that all users have a consistent set of styles and tools for working on a particular project. For example, if your team is writing a book, you can create a document template the writers use as the basis for each section.

Creating a Custom Document Template

To create a custom document template, click New on the File menu, select General Templates from the templates menu, then click the General tab, click Blank Document, and then select Template under the Create New section.

Note   By default, custom command bars are saved in Normal.dot. To save a command bar with a custom document template, create the command bar by clicking Customize on the Tools menu, clicking the Toolbars tab, and then clicking New. In the New Toolbar dialog box, click the document template's name in the Make toolbar available to list.

Creating a New Document Based on a Word Template

To create a new document based on your custom template, click New on the File menu to open the New dialog box. Your template should appear on the General tab or on one of the other tabs if you saved it in a subfolder of the Templates folder. Click the template, and then click OK.

In addition, you can attach a custom template to an existing document. Doing so will not add any text that is in the template to your document, but any code, styles, and toolbars in the template will be available to your document. On the Tools menu, click Templates and Add-ins, and then click Attach to find and attach your document template.

If you look at the VBA project for a document that has a custom document template attached, you will see that three projects appear in the Project Explorer in the Visual Basic Editor: the document's project, the custom template's project, and the Normal template's project. You can write code in any of these projects. In addition, you can call a procedure in the Normal template or in the custom template from a procedure in the document's project.

Note   When you create a document based on a template, that template appears in the document's References folder in the Project Explorer. If you open the References dialog box by clicking References on the Tools menu, you will see that the template appears selected in the list of available references. Attaching a template to a Word document sets a reference to the template's VBA project, making the code that is in that template available to any procedure in the document.

See also

Word Templates | The Normal Template | Word Document Templates vs. Word Add-ins (Global Templates) | Designing and Deploying Office Applications

Show: