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-2017 by Barry MacDonnell. All Rights Reserved.

Page updated Oct 31, 2016

WordPerfect Tips
Main tips page | Browse tips

Merge tips for multi-page documents

Some related links -

Merge tips (general tips)

Setting up a mail merge (Corel Tutorial)

See also Print your letterhead page from one printer tray, and second and subsequent pages from another tray for explicit information

Want to use individual watermarks on several pages of a merge? Sometimes this can be problematic. See this thread on WordPerfect Universe for a solution [repeated below in Footnote 2].


[Many of these tips appy to merging single-page documents]

Formattng (fonts, pagination, spacing, etc.)


Two-tray merge printing (merging multiple-page letters using letterhead paper for page 1 and plain paper for subsequent pages)

Resetting margins, headers, footers, etc., in merged documents (merging multiple-page documents so that formatting is identical from record to record)

Producing correct page numbering, footnote/endnote numbering, and line/paragraph spacing with multiple-page merge forms

Method A: Modify the form document's initial style to force page numbering. note numbering, line spacing, etc.

Method B: Use a simple embedded macro in the form file.

Formattng (fonts, pagination, spacing, etc.)

Be sure to explicitly set your merge form's basic format and pagination codes at the top of the merge form document (.frm).

That way, when the second and subsequent merged documents in the merge queue are merged, any changes to formatting or pagination in the middle of the form document (or in a second form document) will be reset to their (user-defined) defaults for each document before it is merged with your data.

Notes and tips ...

1. "Top of the merge form document" usually means the very top of the body text area in the form document, not inside the initial [Open Style: DocumentStyle] code.

An exception is to use the [Open Style: DocumentStyle] code to reset page numbers to "1" as explained in the examples below, but this merely modifies the "top of the merge form document" rule.

On the other hand, other WordPerfect formatting codes can be placed inside the initial document code (see the "Resetting..." section below). Simply test the methods to see which works best for you.

2. If you have multiple form documents in your merge (e.g., a form letter and an invoice document), you should explicitly set format and pagination codes at the top of each merge form document so that each merged document "reads" the specified formatting codes before it merges that item.

3. You can, of course, add different formatting to any part of the merge form document(s).

For example, you could change the font or font size for some (or all) of the variable data areas by selecting the merge field code(s) and applying the new font or size. But it is a good idea to always follow the "top of the merge form document" rule above.

This will force a re-set of all fonts and other formatting at the top of the merge form (and therefore at the top of each merged document) so that a stray format change code further down in the form doesn't carry the changed formatting over to the next merged document.

4. If you need to add paired codes (bold, italics, etc.) to just certain merged fields, see this post by Noal Mellott on WordPerfect Universe, which describes how to add these codes in appropriate places on the merge form. [See the text of his post in Footnote 1.)

Examples ...

Two-tray merge printing

A user on a Corel newsgroup asked:

"I'm trying to merge print a two-page letter where page one is printed on letterhead pulled from one bin while page two is printed on plain paper pulled from a second bin."

Debra Earle (Corel C_Tech) replied with this tip:

". . . it seems to me that you simply need to put an explicit paper size/type at the top of the first page [of the merge form], rather than relying on the default document style, and then [a] delay code for the second page to change the page type."

The explicit paper size/type for Page 1 of the merge form letter can be entered by going to the top of the page, then clicking Format, Page, Page Setup and then (under the Size tab) choosing the page setup for your printer's letterhead tray.

The delay code can be entered on Page 1 with Format, Page, Delay Codes, 1, OK. Then in the Define Delayed Codes window that is now onscreen, use Format, Page, Page Setup to choose your second page's setup from the list. Click OK, then click Close to close the Define Delayed Codes window and return to the main merge form document.

[Page Top]

Resetting margins, headers, footers, etc., in merged documents

Several years ago a user on the WordPerfect Universe asked:

"I am trying to merge a three-page document. The .frm document has a Header (with Subject:, From: and To, a Footer (with page number). The merging is on done on name, address, etc.

How do get the formatting of all three pages identical from record to record? That is to say, after each record the margins should be re-set, the headers and footers should be re-set and the page number should be re-set to 1."

Seth Katz answered:

"You need to include any 'resetting' formatting (page number, margins, etc.) at the top of the first page of the form, even if they are not needed on the first page, since they will be needed on subsequent instances of that page in the merged document. WP will normally delete any 'redundant' codes (e.g., the code setting the page number to [1] on the first page); but it will not do so if you have the merge toolbar displayed (i.e., if the document has been identified as a merge form). ..."

[But: The italicized clause in the previous sentence might not be true for some later versions of WordPerfect. Hence, see the "Producing..." section below for a simple workaround.]

"... If you try to do this in a regular document, the 'resetting' formatting will disappear. You can get around this by either including the 'resetting' formatting in a style and applying the style at the beginning of the document, or by setting dummy different formatting in the [initial] document style [by double-clicking the [Open Style] code in Reveal Codes, at the very top of the document], then changing the formatting to what you want at the top of the first page. Since these formatting codes are no longer redundant, they will not be automatically deleted."


☼  It helps to think of WordPerfect formatting as codes-in-a-stream, where formatting can affect downstream material unless that formatting is discontinued or replaced by formatting of the same type. So, with the trick above, you are essentially forcing all specified formatting to be reset (i.e., restart fresh) at the top of each and every merged (i.e., output) document, and any changed formatting of that type in a document will only affect that particular document. The specified formatting will not "bleed" over to the next document.

☼  You can also reset various values (e.g., page numbering, margin settings, etc.) at the top of the merge form inside the document's initial [OpenStyle] code. See the "Producing..." section below about resetting page numbering (you can also use a similar method to reset page margins).

☼  However, the "resetting" of some things like the display of headers, footers, or watermarks might be best done by adding "discontinue" codes (using the Insert menu) at the very bottom of the merge form.

¤  This is because the program needs to have an existing header (or footer or watermark) in the document before it can discontinue it. Also, inserting "dummy" values for these items inside the merge form's initial style code (as can easily be done with page numbers and margin settings; see below) is sometimes problematic for users. (For more about headers, footers, and watermarks see here.)

[Page Top]

Producing correct page numbering, footnote/endnote numbering, and line/paragraph spacing with multiple-page merge forms


For general information about -

Page numbering:
"Page Numbering in WordPerfect".

Footnotes and endnotes:
"Footnotes and Endnotes: Setting or changing margins, numbers, font sizes, tabs and other formatting in WordPerfect notes".

Line spacing and paragraph spacing:
"How to double space text or add other custom line or paragraph spacing".

Method A: Modify the form document's initial style to force page numbering. note numbering, line spacing, etc.

A user on WordPerfect Universe asked:

My .frm [i.e., form document] has four (4) pages and are numbered. When I merge, I end up with the pages numbered as it if is one document -- which I realize it technically is, but I need it to be numbered ... 1,2,3,4 ... 1,2,3,4 ...

My answers:

First, about forcing correct page numbering in multiple page merged documents:

[From the Corel support database (http://support.corel.com), Answer ID 203229 [which, though it applies to WordPerfect 9, should work in other versions]

"How to set Page Numbering in a Multiple Page Merge Document for WordPerfect® 9


When merging information to a form file containing Page Numbering, a Page Numbering code is needed at the top of the first page in order to restart each copy of the merged document with page number one. The Page Number Set code cannot be placed on the first page of the form file because the first page is already page one and the program is designed to remove unnecessary (duplicate) codes. [Emphasis added.]


The workaround is to force the page number, in the Document Initial Codes, to a value that is not equal to 1 and then reset it back to 1 on the first page of the form file. The following instructions will force each of the merged forms to start over with page one.

1. Place the insertion point at the top of the form file. Click on Format, Styles, Document Styles.

2. Select Edit. 

[Ed: Note that steps 1 and 2 can also be done by simply double-clicking on the [OpenStyle:DocumentStyle] code at the very top of the document; either way, this opens the Styles Editor for the next step.]

3. Select Format, Page, Numbering, Set Value [from the Styles Editor's menu].

4. Change the 1 to a number higher than the number of pages in your form file. (If you have 3 pages in your form file, you will want to set the number to 4 or higher [such as 99, just to be sure]).

5. Select Apply, OK, OK, OK, Insert.

6. Now put the insertion point at the top of the first page of the form file [before all codes and text]. Click on Format, Page, Numbering, Set Value and set the value to 1.

7. Select Apply, OK, OK.

8. Save the form file and perform [the] merge."

Second, if you are using numbering inside headers or footers:

You'll probably want to remove the [Pg Num Pos] code in the Styles Editor during Step 5, leaving just the [Pg Num Set] code. (Or, when you are in the Page Numbering Styles Editor, change the 'Position:' drop list selection to 'No Page Numbering'; no [Pg Num Pos] code will be inserted.) Page numbering will then be accomplished by the page number code you will have inserted into the header or footer -- justified as needed -- with Format, Page, Insert Page Number (or just press <Ctrl+P> ). ...

... the 'Details' paragraph from the Corel article above gives an explanation of why the workaround works: The program is designed to remove any extra [Pg Num Set] code that you would (normally) have inserted when trying to set that page number to '1' with Format, Page, Numbering, Set Value.

So the workaround first 'tricks' WP into thinking that the current page number is '10' (or whatever higher value you set it to in Step 4). Next, it 'sees' the new [Pg Num Set] code at the top of the body text area of the document (which has been set to a value of '1'), so it uses that value for the current page. The last code takes precedence in this case.

It makes sense if you think of WP as 'stream-oriented.' That is, most formatting starts at one location in the 'stream' of characters and codes and continues until replaced or discontinued by another, relevant code. (Hence the reason why Reveal Codes is so valuable in troubleshooting formatting in WP.)

[Side note: For more on using page numbering inside headers or footers in ordinary documents -- such as "Page x" or "Page x of y" -- see footnote #6 here on the Headers, Footers, and Watermarks page. Also see the other "page numbers inside a header or footer" footnotes on that page.]

Third, for footnote numbering and/or endnote numbering, line spacing, and paragraph spacing:

At least one user reported that this "hide-a-code" trick works to reset footnote numbers to "1" at the top of a multi-page document. (Curiously it is not necessary with endnotes, which allow you to force a value of "1" at the top of a document.)

It should also work for (Format>Line>Spacing) and Line SpacingParagraph Spacing (Format>Paragraph>Format), as well as for any feature where you can't (normally) set the value to "1" at the top of a document to force the merge to start with the minimum (number) value.

Method B: Use a simple embedded macro in the form file.

To force the first page's number to "1", here is a tip from Greg Turner at WordPerfect Universe. [Note that the first steps are optional, since they refer to setting up a "Page X of Y" page numbering format in the merge form.]

"1. [Optional:] Go to the [top menu] and click on Format|Page|Numbering...

[Optional:] Select the format "Page 1 of 1"

[Optional:] Click on "Okay" button

4. With the merge form toolbar on -

a. Click on Insert Merge Code|More


c. Click on Insert

d. Within the EMBEDMACRO() type in "PageNumber (Page:1)" to get:
EMBEDMACRO(PageNumber (Page:1)).

If your form has pages that follow the numbered section, that you do not want numbered, you can use some combination of Suppress(PageNumbering!) and DelayCodes() within an EMBEDMACRO()."

[Page Top]

Footnote 1

[...continued from above...]

Here is the text of Noal Mellott's WordPerfect Universe post:

"When inserting formatting codes, in particular paired ones, be sure that the merge process encounters the code in the frm-file at a position before merging a field or record and that the Off-code, if any, is encountered immediately after merging it.

A practical example: Where might you place the Italics on/off codes in the following?


To italicize any action taken:
[ItalicsOn] IFBLANK(5) FIELD(5) ELSE FIELD(6) ENDIF [ItalicsOff]

To italicize only the text inserted from field 5:
IFBLANK(5) [ItalicsOn] FIELD(5) [ItalicsOff] ELSE FIELD(6) ENDIF

To italicize only the text inserted from field 6:
IFBLANK(5) FIELD(5) ELSE [ItalicsOn] FIELD(6) [ItalicsOff] ENDIF

But what will happen if you use the following?
IFBLANK(5) [ItalicsOn] FIELD(5) ELSE FIELD(6) [ItalicsOff] ENDIF
In this case, if the merge encounters a fifth field with text it will turn italics on, and the italics will never be turned off until, when processing some later record, the merge encounters a blank fifth field and inserts the sixth field instead."

Footnote 2

[continued from sidebar above...]

Want to use individual watermarks on several pages of a merge? Sometimes this can be problematic. From this thread on WordPerfect Universe:

How to "hide" multiple [Watermark] images used in a multi-page merge.

Assume you have created three watermark images, each of a different page of a scanned paper form, separated by hard page breaks in the body text area of the document.

You want to merge data on top of each of the pages [i.e., directly over the watermark images] at the appropriate locations on each page, but you do not want the [Watermark] codes to be pushed away from their assigned locations by the merge data.

Step 1. Create the three watermark images. You can store them temporarily in a new, separate document. Open the separate document on screen so it is available; be sure to open Reveal Codes, too.

Step 2. Select the first watermark image (the one which should be seen on page 1 of the merge form); perhaps you can select the image's code in Reveal Codes (this is most easily done with <Shift+arrow>), or just right-click on it to choose "Select Box" or similar from the context menu that pops up. Copy the selection to the Windows clipboard with <Ctrl+C>.

Step 3. Open another new blank document. At the top, open a watermark window with Insert, Watermark; choose Watermark A, then click Create. In this new window, paste the copied image with <Ctrl+V>, then close the window with the "Close editor" icon on the property bar or with File, Close on the main menu. You should now see a new [Watermark A] code in Reveal Codes.
  • Tip: While inside the watermark windows, set the images to 100% shading with the Watermark Shading button on the watermark property bar, and resize the images to fill the page.
Step 4. Go back to the first temporary document (see Step 1) and select the second watermark image (the one which should be seen on page 2 of the merge form); copy it to the Windows clipboard with <Ctrl+C>.

Step 5. Return to the new document (created in Step 3). Place your cursor after the [Watermark A] code in Reveal Codes if it is not already there.
  • Click Format, Page, Delay Codes and enter a "1" (without quotes) in the "Number of pages to skip" field.
  • Click OK.
You are now in the Define Delayed Codes window (you should see [Define Delayed Codes (Watermark A)] in the title of the WordPerfect window). Then:
  • click the Watermark button on the property bar;
  • select Watermark A in the dialog, and click Create;
  • paste the second watermark image into this window;
  • set the intensity and size (see the Tip above in Step 3);
  • click File, Close;
  • then (in Define Delayed Codes) click Close to return to the main document.
You are now back in the main document area.
You should see [Watermark A][Delay: 1] codes in Reveal Codes.

Step 6. Place the cursor after the two new codes (in Reveal Codes). Repeat Step 4 and Step 5, using the third image -- BUT in the Delay Codes dialog, enter a "2" in the "Number of pages to skip" field. [You want to delay image #3 to page 3.]

You should see [Watermark A][Delay: 1][Delay: 2] codes in Reveal Codes.

So far, so good.

You can now test the new document by adding a couple of hard page breaks (<Ctrl+Enter>) following (i.e., after) the [Watermark A][Delay: 1][Delay: 2] codes in Reveal Codes. This should produce a three-page document with the three images in sequence.

After testing, remove the two [HPg] codes, retaining just the [Watermark A][Delay: 1][Delay: 2] codes in Reveal Codes.

But ... you need to perform one more procedure or these new codes might get pushed down or be accidentally deleted during the merge:

Step 7. Hide the codes: Select just the three new [Watermark A][Delay: 1][Delay: 2] codes in Reveal Codes (this is most easily done with <Shift+arrow>), and cut them to the clipboard with <Ctrl+X>. [Cutting them removes them from the main document, which is exactly what we want to do.]

Step 8. Double-click on the [Open Style: DocumentStyle] code at the top of the document (or in any document you wish to use as the new merge form). This opens the Styles Editor for the document's default style.

Step 9. Paste the three codes into the Contents field (usually after all other codes) with <Ctrl+V>, then click OK. You should be back in the main document.

In the main document you should see the first image on the screen, on page 1 of the document. You can add two temporary page breaks (with <Ctrl+Enter>); the other two images should appear on pages 2 and 3. [Note: Be sure to remove the temporary [HPg] codes and anything else you might have added before the next step.]

Step 10. Finally, create (or copy) both your merge form's text and merge fields in the new document, on the relevant pages and page locations.

You can use borderless tables to help format the merge form itself, and/or Format, Typesetting, Advance for precise location control. Add a hard page break to separate each page.

[Step 10 alternate:] You might be able to simply insert the three new codes into the original merge form's [Open Style: DocumentStyle code] code, and delete the old [Watermark] and [HPg] codes. However, it seems less problematic -- maybe less confusing -- to start fresh with a new form document.

Reminder: Be sure to edit the initial style code (see Step 8) if you need to revise or delete the [Watermark] codes!

Strong suggestion: If you need to revise such hidden codes later, it is usually better to select the codes in the Contents pane of the Styles Editor (they were placed there in Steps 8-9 above), cut them (<Ctrl+X>) to a new blank document, edit them there, then paste them back into the same Contents pane. Why? Sometimes, trying to edit a format code that is located inside a style code will cause WordPerfect to freeze and force you to stop the program with <Ctrl+Alt+Delete>. Some codes encapsulated inside a style (via the Styles Editor) cannot be modified once they are in there, but you can edit them if they are temporarily moved into the body text area of a document.

[Page Top]