Microsoft KB Archive/122991

{|
 * width="100%"|

WD: How to Create a Template to Automatically Update All Fields

 * }

Q122991

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows 95, versions 7.0, 7.0a
 * Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

-

SUMMARY
This article contains instructions for creating a template that automatically updates all fields in a document, including fields contained in the header and footer areas. This article includes the following sections:


 * Steps to Create the Macro
 * Steps to Insert the CreateDate Field
 * Creating a Toolbar Button to Automatically Select Your Template

MORE INFORMATION
Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Partner or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Partners, please see the following page on the World Wide Web:

"http://www.microsoft.com/partner/referral/" For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

"http://support.microsoft.com/directory/overview.asp"

Steps to Create the Macro
Create a macro to automatically update all fields by following these steps. Because the macro is called AutoNew and is stored in your template, this macro is available for all new documents you create based on your template.


 * 1) From the File menu, choose New.
 * 2) Choose the Template option and click OK to create a new template based on the Normal template.
 * 3) On the Tools menu, choose Macro.
 * 4) Type AutoNew in the Macro Name text box and click Create.
 * 5) Using the following example, type the text that appears between the Sub MAIN line and second End Sub line.
 * 6) Save and close the macro.
 * 7) Save and close the template.

Steps to Insert the CreateDate Field
The CreateDate field inserts the date and/or time a document was first created. Using the template in which you created your macro, follow these steps:


 * 1) On the View menu, choose Header And Footer.
 * 2) Click the "Switch Between Header and Footer" button on the Header And Footer toolbar if you want to place the CreateDate field in the footer.
 * 3) On the Insert menu, click Field.
 * 4) In the Categories list, select Date And Time, and select CreateDate in the Field Names list.
 * 5) Click Options.
 * 6) Select the appropriate Date-Time format.
 * 7) Click Add To Field.
 * 8) Click OK twice.

Creating a Toolbar Button to Automatically Select Your Template
To add a button to your toolbar that automatically creates a new document based on your template, follow these steps:

On the Tools menu, click Macro.

In the Macro Name box, type a name such as NewDocInMyTemp.

Click Record.

Click Toolbars.

In the Save Changes In list, choose Normal.dot.

Drag the NewDocInMyTemp macro onto the appropriate toolbar.

Select a toolbar button and click Assign.

Click Close.

Record the following steps:

 On the File menu, click New. Click to select your template and then click OK.

Click the Stop button on the Macro Recorder toolbar.

Save and close the template.

For information about how to do this in Word 97, please see the following article in the Microsoft Knowledge Base:

"Q159824 How to Automatically Update Fields in a Document or Template" Additional query words: auto new open automatic template macro wordbasic

Keywords : kbprg kbtemplate kbmacroexample winword macword word6 word7 word95

Issue type : kbhowto

Technology : kbWordSearch kbWordWSearch kbWordMSearch