Home | Tips | Library | Other Authors | Other WP Sites | Writer's Links | Contact | Site Map | Donate

Barry MacDonnell's
Toolbox for WordPerfect

Macros, tips, and templates for Corel® WordPerfect® for Windows®
© Copyright 1996-2021 by Barry MacDonnell. All Rights Reserved.

Page updated Jul 16, 2020

FILENAME STAMPING macros that put the document's filename and optional text on every page in the footer or header of your choice, or just on the last page of the document

Download FILSTAMP.ZIP (FilenameStamper.wcm, v1.03, 06/02/18;
FilStamp.wcm, v1.04, 07/12/04;
ZIP file=25,517 bytes)

FilenameStamper.wcm is for WordPerfect 8 and later versions

FilStamp.wcm is for WordPerfect 6 and later versions

WordPerfect 11 users: See important information about using macros in the first release of WP11 (11.0.0.233) at the top of this page.

Downloading, Documentation, Modifications, and Support

Macros with a similar purpose:

DocStamp - A macro that will toggle the display of a user-specified document text stamp—such as "DRAFT" or "COPY"—on and off.

EdgeText - a macro that places a short block of text, the date, and/or the filename at one of six places around the edge of the page, outside the page margins.

DateRepl - Macros that can change all Date codes (dynamic dates) to text (static dates)

See also: QuickWords for another way to insert items in a document.

Two macros are included in the download Zip file:

•  FilenameStamper.wcm and
•  FilStamp.wcm

FilenameStamper.wcm

Purpose and advantages

FilenameStamper.wcm displays a menu (screen shot) when you play it.

Depending on your choices, it
places the filename at the bottom of Footer A or Footer B, or at the top of Header A or Header B, starting on page 1. Footer A is used by default. If it exists the macro will edit it; if it does not, the macro will create it.

Thus you can use FileStamper in the same footer or header as other material. (See Operation below about issues with other headers or footers further in the document.)

Also, while WordPerfect ships with a macro (FileStmp.wcm) that puts the filename in a footer or header, it does not automatically remove old filename stamps the way this macro does. (See Footnote 1)

Operation
Other options are available on the pop up menu:

•  Insert just the filename (no path)
•  Add a print date after the filename, in one of several date formats
•  Justify the inserted material left, center, or right
•  Adjust the relative font size and intensity (text shade) of the filename stamp
•  Suppress the display of the menu or exit message (see macro's code)

You can modify the default menu choices for these options in the redlined User Modification Area. See Footnote 2.

The macro uses a special paired-code bookmark ("FilenameStampLocationMarker") to locate and place the filename stamp.

If a bookmark already exists in the document from a prior use of the macro, the bookmark and adjacent filename stamp are deleted, then re-created to ensure that only the most up-to-date stamp is used.

Be aware that if you insert another header or footer of the same type (A or B) later in the document, the new header or footer will replace the old one, and your filename will not show from that point onward. If this is likely, choose the header or footer (A or B) least likely to be impacted by additional inserted headers or footers.

Note also that if the current file has not yet been saved (and therefore is unnamed), playing the macro will cause the Save As window to appear. If you Cancel the Save As window, no file stamp will be inserted.

This macro may be a good candidate to use as a template macro triggered at print time. Or you can simply assign it to a toolbar button or keystroke combination. (See Tips below.)

Note and tips

This macro (unlike the FILSTAMP macro below) inserts a [Filename] code in the document (visible in Reveal Codes).

You can convert that code into a string of text characters so that the filename (and path, if used) becomes more permanent -- i.e., it won't dynamically change if you rename the document, as would be true using the [Filename] code to display the current file's name (and path if used).

You can do this in at least two ways.

Method A

If you just want to convert it to text manually when editing any document:

1. In the Reveal Codes window, select just the [Filename] code (Shift+arrowkey is the easy way), then

2. immediately paste the selected code back in the same place as Unformatted text (there's a choice for that on the context menu if you right-click with your mouse -- or you can use Edit> Paste Special> Unformatted Text).

Method B

You can also use a macro to -

1. search for each [Filename] code, and when found,

2. select it,

3. copy it to the clipboard with EditCopy, and then use

4. EditPaste ("Unformatted Text";1; OLE!) to replace that code with the filename as plain text.

For example, this small macro converts all [Filename] codes to plain text:

// Macro code begins here

pExitSubstructures ()
PosDocVeryTop
OnNotFound(EndNow@)
MatchSelection
While(True)
    SearchString(NToC(64395))  // NToC(64395) = [Filename] code
    SearchNext(Extended!)  // <= Include Headers, Footers, notes, etc.
    EditCopy
    EditPaste ("Unformatted Text";1; OLE!)
Endwhile
Label(EndNow@)
Return

Procedure pExitSubstructures ()
// Exit from any header, footer, footnote, endnote,
// text box, graphic caption, etc.:
While (?Substructure)
    vSubDoc:=?CurrentSubDoc
    SubstructureExit
    If ((vSubDoc=10) or (vSubDoc=11))    
        BoxEnd (Save!)
    EndIf
EndWhile
vBoxType:=?BoxContentType
If (vBoxType=1 or vBoxType=3) BoxEnd (Save!) Endif
EndProc

// Macro code ends here

¤  To copy this code into your WordPerfect program to create a working macro see here.

¤  For macros that can replace [Date] codes with plain text see DATEREPL in the Library.
Page Top

Filstamp.wcm
This macro stamps your documents with identification on just the last page (only) of the document.

Operation:
1. FILSTAMP goes to the bottom of the current document and inserts two hard returns, then types the complete filename (drive and pathname), plus your initials or other indentifier such as "DRAFT COPY" (see the redlined User Modification Area in the macro's code to change the default identifier, etc.).

2. It then types the date and time the file was last edited (i.e., saved), as a text string so that this date indicates the edit date.

3. Finally it types the date it was printed as a [Date] code so that this date will change if you print a copy of the document on some future date.
If you make changes to the document, run FILSTAMP again to update the stamp.
The default file stamp -- printed in 7-point Arial -- looks something like this:
C:\My Documents\Sample.wpd [DRAFT COPY]
Edited: January 19, 2019 (9:07am) Printed: January 19, 2019.
The date and time can be omitted by selecting a check box when the macro is played. The macro looks for an existing file stamp and erases it before it stamps a new one.

The macro can be used as a template macro to automate stamping. Or you can simply assign it to a menu, toolbar button or keystroke combination. (See Tips below.)

Page Top

Tips
☼  You can assign a macro to a menu, toolbar, or keystroke combination.

☼  You can use a file macro (i.e., one on your disk) as a template macro (i.e., embedded inside the template itself), and have it play whenever you print the document.
To do this, copy the file macro into the appropriate template and associate it with the PRE PRINT trigger, like this:
•  Edit the template on which the current document is based. (See WP's online Help <F1 key> for more information.) When the template is open for editing, click the Copy/Remove Objects button on the Template Property Bar.

•  In the Copy/Remove Template Objects dialog that pops up, select "Macros on Disk" from the Object Type drop list, then choose the name of the macro in the Source drop list.

•  Click the Copy>> button, then click Close to close the dialog window. The macro should now be embedded inside the template as a template macro (as distinguished from a file macro -- i.e., one that is simply stored on your disk).
 
•  Back in the template editing window, click the Associate button on the Template Property Bar. Click the Triggers radio button, then select Pre Print in the left window. In the Macros drop list, choose the name of the template macro and click OK. (You can always remove the associate with Pre Print by selecting No Association.)

•  Save the template with File, Save. Test the operation of the macro by loading a new document based on the template, typing some text into it, and then printing it with File, Print.
If you need to edit the template macro later, while editing the template click on Tools, Template Macro, Edit.

Note that only template macros can be associated with a trigger. Macros on disk cannot be associated with template triggers, but they can be copied into the template first with Copy/Object on the Template Property Bar, and then associated with a trigger, as described above.

The two most common triggers used with simple template macros are Post New (play on opening a new document based on the template) and Pre Print (play at print time). For more information on triggers, see the WordPerfect help file topic, "Triggering macros from templates" and "'Trigger' a macro from inside a template to play automatically at specific times."


For more information about automating templates, see "Automating WordPerfect Templates" in the top section of the Tips page here.
Note also that the template on which all new documents are based (the "default" template) is named "Create a blank document," and is usually found in the Custom WP Templates section of your File, New from Projects list. On disk, the default template's filename is something like WP19US.WPT, where 19=WordPerfect X9, and US=the US language versions. For the actual location on your system, in WordPerfect click on Tools, Settings, Files, Template tab, and look at the data in the Default fields.
 
Page Top

Footnote 1

The FILESTMP macro that ships with WordPerfect is designed to place the filename in a header or footer -- both of which are "repeating elements." That is, they show up on every page until replaced or discontinued. Unless the cursor is positioned on the last page and no header or footer exists of the type (A or B) you choose, when you play the FILESTMP macro any existing header or footer will be modified (it's due to the way the macro is coded).

While it is possible to modify the FILESTMP macro's code to make the filename show up on the last page regardless of any existing header or footer -- as mentioned, new headers/footers "discontinue" previous ones of the same type -- it might be easier for you to use one of the macros above.

In particular, Filstamp.wcm makes the filename-stamping process more reliable, since it does not impact existing headers or footers -- which would be especially important if the user modified the document extensively, and then played the macro again.


Footnote 2

Note that a macro is a WordPerfect file with a ".wcm" filename extension, and can be opened, viewed, and edited like an ordinary document. Most of the macros on this site have information or instructions at the top of the main macro code. Most have a redlined section in the macro's code that users can modify, something called the "User Modification Area." Follow the instructions there to modify various macro defaults, such as initial menu choices or initial values for the macro to use when it processes the document.

Page Top