Microsoft Office 2000/Visual Basic Programmer's Guide |
Word add-ins and document templates both have the same file extension, the .dot extension. In fact, you can use a template as an add-in, or an add-in as a template.
So what's the difference between the two? The best way to use a Word template is as the basis for new documents. For example, you might create an invoicing template that employees could use to create customer invoices. When users create a new document based on the template, some of the information is available to them already — the name of your company, the date, and so forth. All they need to do is enter the customer name and the items purchased.
An add-in, on the other hand, provides custom tools that employees can use to work with all of their Word documents, like the custom features provided in the UsefulTools.dot add-in described earlier. An add-in extends Word's functionality in a way that can be tightly integrated with Word itself. When you load an add-in, it remains loaded for each document opened in Word, until you explicitly unload it.
The following table summarizes the differences between Word templates and add-ins.
Custom document template | Add-in |
A document template has the .dot file extension. | An add-in has the .dot file extension. |
You can attach only one template to a document. (The Normal template is always loaded whether or not there is an attached template.) | You can load multiple add-ins at the same time. |
A template is attached to a document at the time the document is created, or after the document is created by clicking the Attach button in the Templates and Add-ins dialog box (Tools menu) and selecting the template. | An add-in is loaded by selecting the corresponding check box in the Global templates and add-ins list in the Templates and Add-ins dialog box. |
A template can be used by any document, but it must be attached to each individual document. | Once loaded, an add-in is available to all documents. |
A template adds toolbar buttons, menu items, macros, styles, or boilerplate text to a specific document. | An add-in adds toolbar buttons, menu items, or macros to the Word environment. It doesn't display any boilerplate text or contain any custom styles. |
The attached template can be accessed from VBA by using the AttachedTemplate property of a Document object. Templates are available in the Templates collection. The Templates collection contains the Normal template, the attached template (if any), and any loaded add-ins. | Add-ins in the Global templates and add-ins list, whether loaded or not, can be accessed from VBA through the Word AddIns collection. Add-ins can also be accessed through the Templates collection. |
A reference to the template's VBA project is automatically set when you attach a template to a document. Therefore, you can call procedures in the template's project from the document's project. | No reference is set to an add-in's VBA project when it is loaded. Therefore, although you can call procedures in the add-in project through toolbars, menu items, or macros, you cannot directly call a procedure in an add-in's project from code running in a document unless you explicitly set a reference to the add-in's project. |