WD: How to Insert the File Name of a Document Automatically

ID: Q64171

The information in this article applies to:

SUMMARY

In Word 5.1 and earlier, to automatically insert the name of a document in a Word file, you must use PostScript commands and a graphics box to automatically insert the name of the document in the text of that document.

NOTE: In Word versions 6.x and later, you can use the FileName field to automatically include the name of the file in your document. For more information about using fields in Word, see Word Help.

MORE INFORMATION

To insert the name of a document in the document, use the following steps:

1. Position the insertion point directly above the paragraph where you want

   the name of the document to appear and type the following PostScript
   commands:

      .pic.
      /Times-Roman findfont 12 scalefont setfont 0 0 moveto
      statusdict /jobname get (document: ) search {pop pop show} if

   NOTE: There should be a space before the closing parenthesis after
   "document:".

2. Select the lines of text you typed in step 1, then do one of the
   following:

    - In Word 3.x and 4.0, hold down the SHIFT key and choose All
      Styles or Define All Styles from the Format menu. This command
      will display all of Word's "automatic" styles in addition to the
      styles you've defined. Select PostScript from the list and
      choose the OK button.

    - In Word 5.0 and 5.1, choose Style from the Format menu and select
      the All Styles option. Select PostScript from the list and choose
      the OK button.

3. Position the insertion point where you want the title of your
   document to appear (this should be in the paragraph directly
   following the PostScript instructions) and insert a graphics box by
   doing one of the following:

    - In Word 3.0, choose Insert Graphics from the Edit menu.

    - In Word 4.0, choose Insert Graphics from the Document menu.

    - In Word 5.0 and 5.1, choose Picture from the Insert menu and
      choose the New Picture button.

   NOTE: The resulting graphics box can be resized to fit the document
   name.

The name of your document will appear in the lower-left corner of the graphics box that you inserted in the first non-PostScript paragraph following the PostScript instructions.

To insert either the file name or the file name with its path into a Word 5.0 or 5.1 document without using PostScript commands, insert the Glossary Entry instead.

1. From the File menu choose Save and name the document.

2. Position the insertion point at the place in the document file name is

   to be referenced.

3. From the Edit menu select Glossary (or press Command+K).

4. From the Standard Entries list, select either "file name only" or

   "file name with path," then click on Insert (or press "return").

MORE INFORMATION

The following list describes some of the PostScript commands used in this article:

/Times-Roman   Specifies which font will be used. This command can be
               changed to any installed LaserWriter font. Make sure that
               the name is preceded by a forward slash. Note that even
               though Apple uses the Times font, the PostScript interpreter
               only recognizes the command Times-Roman.

12 scalefont   Specifies the size of the font (in points). Any number size
               can be substituted for the number 12.

0 0 moveto     Defines where the name will appear within the graphic. The
               first number indicates the horizontal distance from the
               lower-left corner, and the second number indicates the
               vertical distance from the lower-left corner. The position
               of the document name within the graphic can be adjusted by
               changing these numbers.

Additional query words: Post Script filename header footer title
Keywords          : kbprint kbfield winword macword macword5 
Version           : MACINTOSH:3.0,3.01,3.02, 4.0, 5.0, 5.1;
Platform          : MACINTOSH Win95 WINDOWS winnt
Issue type        : kbhowto

Last Reviewed: November 26, 1997