Microsoft Office 2000/Visual Basic Programmer's
Guide |
|
Creating a Word Add-in
You should create an add-in when:
-
Your solution doesn't require boilerplate text or custom styles.
-
You want to make some functionality available to any document the user creates, through toolbar buttons, menu commands, or macros.
To create a Word add-in
-
Create a new document template. (For information about creating a document template, see "Word Templates" later in this chapter.)
-
Add code to the add-in and create a new toolbar with buttons that call your code when they are clicked.
-
Compile the project by clicking Compile Project on the Debug menu in the Visual Basic Editor.
-
If you want, protect the project from viewing as described in "Securing an Access, Excel, PowerPoint, or Word Add-in's VBA Project" later in this chapter.
-
Save the template as type Document Template with the .dot extension. By default, a Word add-in is saved to C:\Windows\Application Data\Microsoft\Templates; if you're using user profiles, the default path is C:\Windows\Profiles\UserName\Application Data\Microsoft\Templates. To change the default path for templates, click Options on the Tools menu. Click the File Locations tab, click User templates in the File types list, and then click Modify. If you want the add-in to load automatically when you start Word, save the add-in to the Word Startup folder, as discussed in the following section, "Loading a Word Add-in."
Note You can also modify the default location for workgroup templates in the Options dialog box. Workgroup templates are templates that you share on a network with other users.