WD: How to Create an Automated Form with Fill-in Fields

Last reviewed: March 4, 1998
Article ID: Q142213
The information in this article applies to:
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0, 7.0a
  • Microsoft Word 97 for Windows
  • Microsoft Word 98 Macintosh Edition

SUMMARY

This article describes how to create a simple form that automatically prompts a user to fill in information.

MORE INFORMATION

WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

Follow thse steps to create a template with automatic fill-in fields:

  1. On the File menu, click New.

  2. Select Blank Document. (In Word 6.x, select the Normal template.)

  3. Under Create New, select Template (In Word 6.x, select New Template). Click OK.

  4. Create the Fill-in Fields.

    There are two methods you can use to create fill-in fields: menus and keystrokes. Select the method best suited for you.

    Method 1: Creating a Field Using the Menus:

        a. Position the insertion point where you want to insert the
           text field.
    

        b. On the Insert menu, click Field.
    

        c. In the Categories list, select Mail Merge.
    

        d. In the Field Names list, select Fill-in.
    

        e. The FILLIN field is displayed in the Field Codes text
           box below the Categories list. Click inside of the text box
           to the right of the word FILLIN and type quotation marks 
           around the prompt you want to display. For example, use the 
           following syntax to display a prompt asking the user to enter
           their name:
    

              FILLIN "Please enter your first and last name."
    
        f. Click OK. You will see a sample of the prompt. Click OK
           to return to your document.
    
           NOTE: To view the field code you just inserted, press
           ALT+F9 (Windows) or OPTION+F9 (Macintosh).
    
        g. Repeat steps a-f for every place in the document where you want
           a fill-in field.
    
       Method 2: Creating a Field Using Keystrokes.
    
        a. Position the insertion point where you want to insert the field.
    
        b. Press CTRL+F9 (Windows) or COMMAND+F9 (Macintosh). Field
           braces, { }, appear in the document.
    
        c. Position the insertion point inside the field braces.
    
        d. Type the following, where <prompt> is what Word asks the user
           to type:
    
              FILLIN "<prompt>"
    
           NOTE: If you press F9 while the insertion point is still on
           the field, you can see a sample of the prompt that will be
           displayed. This step is not necessary to create the fill-in.
    
    

  5. On the File menu, click Save As.

  6. Name the template appropriately.

Create the Automated Macro

Word 97 for Windows or Word 98 Macintosh Edition:

Word 97 for Windows and Word 98 Macintosh Edition do not require a macro to automatically update FILLIN fields. When creating a new document based on the template created in the steps above, Word automatically updates and displays the FILLIN field.

The following Visual Basic for Applications macro is provided for illustrative purposes only and should not be used within an AutoNew macro. If this macro is included in the template created above, the fillin field will update and display twice.

   Sub AutoNew()
      ActiveDocument.Fields.Update
   End Sub


Word 6.x, 7.x:

  1. On the Tools menu, click Macro.

  2. Type "AutoNew" (without the quotation marks) for the Macro Name.

  3. In the Macros Available In list, select the template name you are using.

  4. Click Create.

  5. Type the following code:

          Sub Main
            EditSelectAll
            UpdateFields
            EndofDocument
          End Sub
    
    

  6. On the File menu, click Close. When prompted to save changes to your template, click Yes.

Once you have finished creating all of the required fill-in fields and text for the template, close and save the template. On the File menu, click Close. When prompted to save changes to your template, click Yes.

Using the Template

To create new documents based on the new template, follow these steps.

  1. On the File menu, click New.

  2. Click to select your template.

  3. Click OK.

Word creates a new document, automatically searches for all fill-in fields in the document and begin to prompt the user for input.

Additional Information

For additional information about creating online forms with form fields, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q141990
   TITLE     : How to Create an Online Form Using Form Fields

You can also use SET and ASK fields in conjunction with fill-in fields.

Word 97 for Windows or Word 98 Macintosh Edition:

For more information about SET fields, click the Office Assistant, type "set fields," click Search, and then click to view the "Field Codes: Set field" topic.

For more information about ASK fields, click the Office Assistant, type "ask fields," click Search, and then click to view the "Field Codes: Set field" topic.

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Word Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q120802
   TITLE     : Office: How to Add/Remove a Single Office Program or 
               Component 

REFERENCES

"Microsoft Word User's Guide," version 6.0, Chapter 14 Forms

"Microsoft Word for Windows User's Guide," version 2.0, pages 480-484


Additional query words: fillin field fields forms auto keyboard merge
automatic automatically vba 8.0 8.00
Keywords : kbfield macword ntword winword word6 word7 word8 word95 word97 wordnt macword98 kbualink97 kbfaq
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a,97; MACINTOSH:6.0,6.0.1,6.0.1a,98
Platform : MACINTOSH WINDOWS


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: March 4, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.