C H A P T E R 39 | Part 6 Microsoft Office Architecture | Microsoft Office Resource Kit |
Microsoft Word Architecture |
|
|
This chapter describes the structure of Microsoft Word 97 for Windows and Microsoft Word 98 for the Macintosh. It explains how the various components of Word work together, and how the application handles changes that users make to those components. An understanding of the architecture of Word can help you take advantage of its features and may help you troubleshoot problems.
|
The architecture of Word consists of three layers:
The application and template layers affect Word documents in different ways. The Word application provides the standard Word menus, commands, and toolbars. Templates serve a dual purpose: they provide a model for creating new documents and also act as a storage container for styles, macros, AutoText entries, and customized Word commands and toolbar settings. The document file contains the text, graphics, formatting, and settings such as margins and page layout for that particular document.
Like templates, a document can also store macros and customized Word commands and toolbar settings. In previous versions of Word, these components had to be stored in templates, making some tasks more difficult for example, when one user wanted to share a macro with another user.
The following figure illustrates how the Word components fit together to create a document.
The key to understanding Word architecture is understanding how the document, template, and application layers interact. Of the three layers, the template layer has the greatest impact on both the document and the application layers.
Templates can provide the following:
Impact of Templates on the Application Layer
You can customize the Word application with templates. Using templates, you can adapt Word menus, toolbars, keyboard assignments, and macros to meet the needs of different types of users or for different types of documents.
For example, you can create a template for new users that includes a toolbar with buttons and menus designed to step them through common tasks. More advanced users, who are familiar with the tasks, do not need the extra guidance and can use a template with toolbar buttons that meet their particular needs.
Impact of Templates on the Document Layer
A template provides a guide or pattern for creating documents. By basing a group of documents on a single template, you or your workgroup can quickly create standard documents, such as letters and memos, with consistent formatting and boilerplate text.
For example, a template for memos can save you time by setting the page margins; inserting the company logo; and providing the text for standard headings, such as Memo, To, and From. With part of the work already done for you, you fill in the additional text.
Attaching Templates to Documents
In Word, all documents are based on a template. When you create a new document, it initially has the characteristics of the active template. The templates available for a new document vary according to how you create the new document, as shown in the following table.
If you use this command | These templates are available |
On the Word File menu, click New. | All Word templates and wizards defined in the User and Workgroup templates locations. These locations are specified on the File Locations tab in the Options (Windows) or Preferences (Macintosh) dialog box (Tools menu). |
On the Office Shortcut Bar or the Windows Start menu (Windows 95 or Windows NT Workstation version 4.0 only), click New Office Document. | All Office templates defined in the User and Workgroup templates locations. Word templates appear on the General, Letters & Faxes, Other Documents, and Web Pages tabs in the New Office Document dialog box. |
Click the New button on the Word Standard toolbar. | The Normal template. The New dialog box does not appear. |
Unless you select another template when creating a new document, Word uses the Normal template, which is stored in the following location.
Operating system | Normal template location |
Windows | Program Files\Microsoft Office\Templates\Normal.dot |
Macintosh | Microsoft Office 98:Templates |
In addition to the Normal template, Word comes with templates for the most common types of documents, such as letters, memos, reports, and mailing labels. You can use the templates as they are or customize them to meet your needs. You can also create your own templates.
In addition to basing a new document on a template, you can attach a different template to an open document.
To attach a different template to a document
Note When you attach a different template, page settings, such as margins, that are stored in the new template are not applied to the document. For more information, see "Default Page Settings" later in this chapter.
Using Global Templates
Items stored in templates other than the Normal template are available only to documents that are based on that template. Items stored in the Normal template, however, are global that is, they are available to all Word documents. These items include AutoText entries, macros, menu assignments, toolbar button assignments, and keyboard assignments.
Using a template designed for one type of document, such as a fax sheet, you can create document settings and commands specific to that type of document. Other commands and components, such as AutoText entries, that you want available to all documents should be placed in the Normal template or some other global template. By using custom and global templates judiciously, you have a flexible method for creating documents that can be highly customized while adhering to companywide standards of design.
Sometimes you may want to use macros, toolbars, or AutoText entries from a template other than the Normal template in many documents. To make these items available to all open documents, you can open the template as a global template. You can then use the customized settings in all your documents. However, styles in the global template are not applied to your documents; Word continues to use the styles from the template on which the document is based. Customized items in the global template are available for the remainder of the current Word session.
To open a template as a global template
The Office Setup program determines default locations for different kinds of Word components: documents, templates, spelling dictionaries, clip art, and so forth. You can change these default locations.
Note The User templates and Workgroup templates settings are Officewide settings. Changing them in Word also changes them for other Office applications that support templates.
To specify file locations for templates and other Word components
Tip In Windows 95 and Windows NT Workstation 4.0, you can use a system policy to define the default file locations for all Word users in your workgroup. In the System Policy Editor, set the following policy: |
User\Word 97\Tools_Options\File Locations
For more information, see "Using Windows System Policies to Customize Office" in Chapter 7, "Customizing and Optimizing Microsoft Office."
When you start Word, the application looks for the Normal template in the following locations, in the order listed:
If Word cannot find the Normal template, it uses the standard document and command settings that have been preset by Microsoft. Any AutoText entries, formatted text, AutoCorrect entries, macros, and command settings that you store for global use in the Normal template are not be available until you return the Normal template to one of the default locations and then restart Word.
Note When Word is first installed, there is no Normal template. It is constructed and saved the first time a user exits Word.
Managing User and Workgroup Templates
In a workgroup, there are usually two places where Word templates are stored: the templates folder on each user's hard disk, and on the network.
Templates used by only a few users or that a user may want to customize (such as Normal, because it is always loaded globally) are usually stored on the user' hard disk. The location of these templates is determined by the User templates setting on the File Locations tab in the Options (Windows) or Preferences (Macintosh) dialog box (Tools menu). By default, Word stores user templates in the Templates folder.
Templates needed by the entire workgroup or that users do not need to customize are typically stored on a shared network drive. The location of these templates is determined by the Workgroup templates setting on the File Locations tab in the Options (Windows) or Preferences (Macintosh) dialog box (Tools menu). There is no initial default setting for workgroup templates.
When a user creates a new document, templates from both the User and the Workgroup templates folders are listed together in the New dialog box (File menu).
Don't Reinvent the Wheel Word 97 (Windows) and Word 98 (Macintosh) include several templates that you can use asis or modify to suit your workgroup's needs. The templates included with Word let you quickly create several types of documents, including:
To see the full list of templates available, click New (File menu), and then click the tab that corresponds to the type of document you want. In addition to the templates that are included with Word, Microsoft may create additional templates available for downloading from the Microsoft Web site. For more information, connect to the Office home page at: |
The various components of Word such as styles, macros, default page settings, AutoText entries, AutoCorrect entries, and custom command settings are stored in the document and template layers of the threelayer architecture. Some components reside strictly in the document layer, others reside in the template layer, and still others are stored in both the document and the template layers.
Of those components that reside in the template layer, some are always stored with the Normal template or the attached template, while others can be stored in a global template. The following table shows what components are stored in the document and template layers of the Word architecture.
This component | Is stored in this layer of the Word architecture |
Document file | Normal or other attached template | Global templates | |
AutoText entries | No | Yes | Yes |
Boilerplate text and graphics | Yes
Copied to the document when it is created | Yes | No |
Custom toolbars, menus, and shortcut keys | No | Yes | Yes |
Default page settings | Yes
Copied to the document when it is created | Yes | No |
Document text and graphics | Yes | No | No |
Macros | Yes | Yes | Yes |
Styles | Yes
Copied to the document when it is created | Yes | No |
Tip To copy template styles to a document when it is opened, select the Automatically update document styles check box in the Templates and AddIns dialog box (Tools menu).
Note In some cases, macros or custom toolbars, menus, and shortcut keys are stored in the template. However, when you specify them by using the Customize dialog box (Tools menu), or when you copy them to the document by clicking Templates and AddIns (Tools menu) and then clicking Organizer, they are stored in the document.
Did You Know?
AutoCorrect entries that include formatted text are stored in
the Normal template. However, plain text AutoCorrect entries are
stored in an external file named *.acl in the Windows folder (Windows) or in the System Folder:Preferences folder (Macintosh). For more information, see "AutoText Entries" later in
this chapter.
|
Text and Graphics
When you create a document, Word copies all information from the template on which the document is based, including boilerplate text and graphics, to the document. From that point on, the text and graphics are saved with the document file. Any subsequent changes you make to the boilerplate text and graphics in the template do not affect documents previously created from that template.
Styles
When you create a document, Word copies styles from the template on which the document is based. However, no link between template styles and document styles is made. So, if you change the styles in the document, those changes are saved with the document file but not in its attached template. Likewise if you change styles in the template after the document is created, those changes are not automatically reflected in the document. However, you can update the document so that its styles match the styles in its attached template.
To automatically update the document styles to match the template
Each time you open the document, Word copies the styles in the attached template to the document.
Tip You can also copy a style from another template to the template attached to the document. On the Format menu, click Style, and then click Modify. Select the Add to Template check box.
Styles Applied by AutoFormat
The AutoFormat command (Format menu) analyzes text in a document and applies styles that have been copied to the document. These document styles originally come from the attached template.
If Word cannot find an appropriate style among those in the document, it uses its own builtin styles. These builtin styles allow Word to format body text, headings, bulleted lists, and other text elements. You can customize these builtin styles.
To customize builtin styles
Note If you select the Add to template check box in the Modify Style dialog box, Word adds the modified style to the template attached to the document. The modified style is available in all documents attached to the template. Otherwise, the style is added to the document only.
The following illustrations show some of the builtin styles you can use to format common text elements.
Style Gallery
You can use the Style Gallery command (Format menu) to see how the appearance of the document changes according to what template is applied. When you select another template in the Style Gallery, Word does not attach the new template to the active document. Instead, it copies the styles from the selected template to the active document. The template on which the active document is based remains attached to the document. To attach a different template to a document, use the Templates and AddIns command (Tools menu).
When Word copies the styles from the selected template into the active document, the styles in the active document are affected as follows:
Word stores default page settings, such as margins, layout, and paper size, in templates. Each new document based on that template inherits those default settings from the template. All subsequent changes made to the settings that are saved with the document remain with the document; they are not automatically saved back to the template. However, you can save settings from a document to its attached template.
To save settings from the document to the attached template (Windows only) |
The new default settings are reflected in all subsequent documents created from this template.
Word stores AutoText entries in templates. To use an AutoText entry in any Word document, store it in the Normal template or another global template. If you want to make AutoText entries available only in documents of the same type as the active document, store them in the template attached to the active document.
To add or edit AutoText entries in a global template, you must open the template in a nonglobal mode. This is because global templates cannot be edited.
To open a global template in nonglobal mode (Windows only) |
To open a global template in nonglobal mode (Macintosh only) |
Tip To determine whether a template is attached to the document or is global, click Templates and AddIns (Tools menu). The template whose name appears in the Document template box is the attached template, and can be edited. The template whose name appears in the Global templates and addins box is a global template and is readonly.
Macros
Together, macros and templates can be used to create a highly customized version of Word designed to accomplish a particular task or set of tasks. For example, a group of macros and templates could be designed to automate the creation of forms and other documents a company uses.
Word stores macros in templates or documents. When you create a new macro, it is stored by default in the Normal template and is available globally. You can also specify which template a macro should be attached to, or store it in the current document.
To store a new macro in a template other than Normal, either the template or a document attached to the template must be active when you create the macro. If you want to create a new macro in a global template, you must open the template rather than a document attached to it. When attached to a document, global templates are readonly.
You can create macros by writing Microsoft Visual Basic for Applications code or by recording a series of actions.
To create a new macro by writing Visual Basic code
Word opens a new macro in Visual Basic Editor.
To create a macro by recording a series of actions
Word displays the Stop Recording toolbar, which you use to pause or end the recording session.
Using the Organizer feature in Word, you can copy macros between documents and templates. Copying macros to documents is especially useful when you want to distribute a document and custom macros throughout your workgroup (through electronic mail, for example), and you want ensure that the document and its macros do not become separated.
To copy a macro to a document or template
If the document or template you want is not open, click Close File. The command switches to Open File; click it and then select the file you want.
If the document or template you want is not open, click Close File. The command switches to Open File; click it and then select the file you want.
The macro is copied from the document or template specified on the left side of the dialog box into the document or template specified on the right side of the dialog box.
Custom Toolbars, Menus, and Shortcut Keys
By customizing toolbars, menus, and shortcut keys, you can change Word to better suit the needs of your workgroup. For example, you can add frequently used commands and dialog box options to toolbars and menus, and remove items users rarely use. You can also customize shortcut key assignments by creating the shortcut keys that work best for your organization.
You can save custom toolbars, menus, and shortcut keys in a template or in a document.
Saving in a Template
If you save the custom settings in a template, you can store them in the Normal template, an open template, or the template attached to the active document. To make customized settings available in any document, save the settings in the Normal template or in a template you plan to make global.
Saving in a Document
If you save the custom settings in a document, you can easily distribute the document and custom settings throughout your workgroup (through email, for example). This ensures that the document and its custom settings cannot become separated.
To customize a toolbar
or
To create a new toolbar, click New; enter a name for the toolbar and select the template or document in which to store it; and then click OK. (The new toolbar appears on your screen.)
To customize a menu
or
To create a new menu, click New Menu in the Categories box; and in the Commands box, click New Menu and drag it onto the Word menu bar.
To customize a shortcut key
In the Current keys box you can see the key combination currently assigned to the command.
As with macros, you can use the Organizer to copy custom toolbars between documents and templates.
To copy a custom toolbar to a document or template
If the document or template you want is not open, click Close File. The command changes to Open File; click it and then select the file you want.
If the document or template you want is not open, click Close File. The command changes to Open File; click it and then select the file you want.
The toolbar is copied from the document or template specified on the left side of the dialog box into the document or template specified on the right side of the dialog box.
AutoCorrect Entries
AutoCorrect entries that use formatted text are stored in the Normal template. These entries have the Formatted text option selected on the AutoCorrect tab in the AutoCorrect dialog box (Tools menu). All plain text AutoCorrect entries, however, are stored in an external files named *.acl in the Windows folder (Windows) or in the System Folder:Preferences folder (Macintosh). All Office applications share these files. When a new user needs an ACL file, it is copied from Mso97.acl and renamed username.acl.
Tip In Windows 95 and Windows NT Workstation 4.0, you can use a system policy to have all users start with a custom ACL file, which you can store on a shared network drive. Use this policy to point to the custom ACL file. In the System Policy Editor, set the following policy: |
Computer\Word 97\Spelling Advanced\Default AutoCorrect File
For more information, see "Using Windows System Policies to Customize Office" in Chapter 7, "Customizing and Optimizing Microsoft Office."
From a user perspective, a wizard is a fast, easy way to create a document because the wizard does the work. In Word, wizards are specialized templates with Visual Basic macros. They are designated with a .wiz instead of a .dot extension (Windows only), and their Type property is Microsoft Word Wizard, rather than Microsoft Word Template. Unlike templates, wizards cannot be modified. The wizards that come with Word all share a common user interface. The key component of the wizard is the macro or set of macros stored within the template. These macros automate the creation of documents.
Word provides wizards to help users create documents such as a fax cover sheet, letter, and resume. Word also includes a wizard to help users create tables. You can create your own wizards to step users through complex tasks specific to your organization. Creating a wizard requires programming in Visual Basic.
For more information about Visual Basic, see the Microsoft Office 97/Visual Basic Programmer's Guide, published by Microsoft Press and available wherever computer books are sold.
Addins are programs written in the C programming language. They act like custom commands or custom features you can use in Word.
Addins place commands on toolbars and menus or assign them to shortcut keys, just as Word macros can. Architecturally, addins fit in at the template layer. They modify toolbars, menus, and shortcut keys just as templates do. You can write your own addins or obtain them from software vendors.
To use an addin, you must load it into Word the same way you load global templates. Like a template, the addin program remains available until you exit Word. If you want to load an addin automatically each time you start Word, store it in the Word Startup folder. For information about creating your own Word addins, see the Microsoft Office 97/Visual Basic Programmer's Guide, published by Microsoft Press and available wherever computer books are sold.
|
Word default settings and paths are established when you run the Office Setup program. After Setup, you can customize these settings for a single user, a workgroup, or across an entire organization.
There are several ways to customize the Word application:
You can customize Word in the Options (Windows) or Preferences (Macintosh) dialog box (Tools menu). The settings you make here are stored in the Windows registry.
In the Customize dialog box (View menu, Toolbars submenu), you can customize the toolbars, menu bars, and shortcut menus included with Word, or you can create your own. For more information, see "Custom Toolbars, Menus, and Shortcut Keys" earlier in this chapter.
A template can include customized Word settings and macros, as well as boilerplate text and graphics. For more information about templates, see "Understanding Templates" earlier in this chapter.
A wizard is special type of template that helps users create specific types of documents. For more information about wizards, see "Managing Wizards" earlier in this chapter.
An addin is a program written in C that adds custom commands and features to Word. For more information about addins, see "Creating Add-ins" earlier in this chapter.
When Word starts, it opens all documents, templates and wizards stored in the Startup folder as specified on the File Locations tab in the Options (Windows) or Preferences (Macintosh) dialog box (Tools menu).
Tip In Windows 95 and Windows NT Workstation 4.0, you can use a system policy to define most settings in the Options dialog box (Tools menu) for all Word users in your workgroup. In the System Policy Editor, set the following policy: |
User\Word 97\Tools_Options
For more information, see "Using Windows System Policies to Customize Office" in Chapter 7, "Customizing and Optimizing Microsoft Office."
|
In the discussion of templates earlier in this chapter, you may have noticed that more than one template can affect the working environment of a document. Each document has access to macros, AutoText entries, and custom commands and toolbar settings in the attached template, the Normal template, and any global templates. These templates, as well as addins or the Word application itself, may define a macro or setting in a way that differs from the other templates or addins associated with the document.
The definition or setting that takes precedence is the one that resides closest to the document. Therefore, Word resolves such conflicts in the following order of priority:
If several global templates have conflicting settings, Word resolves
the conflicts in the order in which the templates are listed in
the Templates and AddIns dialog box (Tools
menu). Templates in the Word Startup folder appear at the top
of the list and have a higher priority. Subsequent ranking on
the list is determined by alphabetic order.
|