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

Page updated Sep 15, 2023

SWAPRECS - Swaps records in a (merge) data text file or data table file

Download SWAPRECS.ZIP (09/08/23; 18,901 bytes)

Compatible with WordPerfect 9 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


Some related resources -

•  For more on data file formats and other WordPerfect merge topics, see your WordPerfect's Help module (F1) and search "Creating data for a merge".

  Merge tips - various tips relating to WordPerfect's merge feature

Macros & Merges Forum on WordPerfect Universe (peer support site) 

To produce sheets of identical (i.e., not merged) content on cards and labels, see LablCopy.



SwapRecs.wcm (v1.02) is a macro that swaps the position of every other record in a WordPerfect data source file (i.e., data text file or data table file) to allow correct front/back printing of individualized 2-column cards such as Avery® business cards.

This produces a data file that will properly merge/print the reverse side of the cards (e.g., on "4-up" cards or "10-up" business cards) with your custom, personalized information on both sides.

Update Sep 13 & 15, 2023 Caution:

A very small number of WordPerfect's 2-column, postcard size, Landscape oriented card formats (accessed via Format, Labels) apparently do not allow typing text or inserting other material on the FULL WIDTH of the card
at least on some systems.

Affected Avery® cards formats:  
3263, 3297, 3378(L), 3380(L), 3381, 8316(L), 8383(L), 8387

This appears to be an issue in recent versions of WordPerfect but it has not been widely confirmed. It might affect only a small number of systems due to their unique setups or other factors.

Note that other card and label formats i.e., cards in Portrait orientation or in a single column, or labels of various types do not seem to be similarly affected.

You can easily test this:

Before attempting to employ the information on this page (below) with those specific card formats, open one or more one of them with Format, Labels and see if you can type some text the full width of the card.

If the text wraps midway on the card rather than at the right side, the problem exists for that particular card format.

This seems related to the printer driver in effect with that format (File, Print, Destination...). Perhaps this only affects driver choices for physical printers, since choosing a virtual printer in the Destination field (e.g., Microsoft XPS Document Writer or
Corel PDF Creator) allows text to wrap at the card's right side, as expected. But these choices are not useful when the task is to print those cards directly to a physical printer.

If you have this problem with an Avery card format, please
ignore this page until this issue can be resolved.


Example


When you merge print the front side of 2-column cards, you'll get them in this order -

[Fig. 1. Showing FRONT side of printed card stock sheet]

Card 1
Record 1
Card 2
Record 2
Card 3
Record 3
Card 4
Record 4
Card 5
Record 5
  ... etc.

WordPerfect always prints them in order -- left-to-right, top-to-bottom.

But when you turn the card stock over horizontally to print on the back side, the individual cards will be printed in the same left-to-right order — but the merged content on the back side of every card will not be synchronized with its front side.

[Fig. 2. Showing BACK side of printed card stock sheet]

Card 1
Record 2
Card 2
Record 1
Card 3
Record 4
Card 4
Record 3
Card 5
Record 6
...etc. 

Obviously, left-to-right printing custom cards will then result in printing Record 2's rear-side content on the same physical card as Record 1's front side.

SOLUTION

The
SwapRecs.wcm macro works on your original data file (make a back up copy of it first).

It revises that data file's structure by swapping the position of every other record in the data file.

Using the revised data file in a second merge, you can then rotate all the card sheets horizontally and run that merge to produce the back sides of all cards. They will be on the same card stock, in proper order, so that each card is associated with the same entity on both front and back, as in Fig. 1 above.

IMPORTANT

¤  The macro works only on WordPerfect data files (either data text file format or data table file format) — not on address book entries, spreadsheet files, databases, or other formats. [But you can, of course, merge address book entries to a data table file first.]

¤  When you play the macro a menu will appear with some instructions and other information. (Repeated below in the next section.)

¤  As states, the macro creates a revised data file of your original data file -- it does not perform any merge of the data to a Form file. The manual steps to set up and run the two merges of your data to both sides of the cards are outlined below.

¤  It is recommended that you print a test with a few sheets from both print runs using ordinary paper to ensure the output is correct before printing on card stock.

¤  Included in the downloadable ZIP file is a one-page document that gives instructions on how to create merge forms for the front and back of 2-column cards, and then perform the two merges using the two data files -- original and revised. PLEASE READ IT.

¤  the macro file SwapRecs.wcm can be opened for viewing or editing (Tools, Macro, Edit). There are instructions at the top of the macro file and a User Modification Area to let you set your default choice on the menu.

HOW TO CREATE THE REVISED DATA FILE

Step 1. Open the data file to use for the cards. (We'll call it the "original" file)

Be sure you meet these conditions before Step 2:

•  The data file should contain ONLY data records.

•  For data text files (ONLY)
:

The cursor must be placed at the very beginning of the FIRST ROW in the FIRST DATA RECORD before playing this macro.

The LAST DATA RECORD in the data text file should end with a single Hard Page code [HPg] following its ENDRECORD code.

•  For data table files (ONLY):

The cursor must be placed in the FIRST DATA ROW in the table.
(Note that data table files may have a FIELDNAMES row at the top; this is NOT the first data row.)

Tip: You can delete empty table rows (i.e., blank records) before playing the SwapRecs.wcm macro. See the author's DeleteRC macro for a quick way to do this.

•  Leave the data file open for Step 2.

Step 2. Play the SwapRecs.wcm macro on that open data file, then save that data file with a different name to preserve the original file. (Or, play the macro on a copy of your data file, then save it with a different name.)

This revised data file is the one you will use to merge to the data fields on the back side (reverse side) of the cards.

The revised data file contains all of the same data (records and fields) as the original data file but with every two records listed in reverse order.

You will need to create a separate Form file for the back side of the cards: See next section below.

HOW TO SET UP THE FORM DOCUMENTS TO USE WITH YOUR DATA FILE (2-COLUMN CARD STOCK)

The first of these two Form documents will use your ORIGINAL data file for the FRONT of the cards, and second one will use the REVISED data file created with SwapRecs.wcm (above) for the BACK of the cards. 

While both merges use different Form documents and different versions of your data file, note that the data files' records and their contents are the same  — only their positions in the data files are different.

Reminder

You should have already created (and saved to disc) a revised data file with SwapRecs.wcm before proceeding. (See the previous section about how to do this.)

Tips

If you need help setting up these Form files see the Merge tips page for some links and other information.

You can also see Doug Loudenback's 4-step tutorial "Using WordPerfect's Merge To Create Mailing Labels" — which is very similar to the steps outlined below. Note that Doug used a QuattroPro sheet for the data file but the principle is the same when using WordPerfect tables as data files. Doug also used small address labels for the output but the method can be used for any WordPerfect "label" stock, including postcards and business cards (which WordPerfect includes with its Labels module).

Method

Step 1. The Form file we will use is an Avery "label" for 2-column postcards.

Open it in a new blank document with Format, Labels, and choose a 4-up (2x2) format for postcards (e.g., Avery 8387 -- but there may be others).

Avery8387 postcard format
[Fig. 3]

The document that opens should show a single, small logical "page" representing the first card on the sheet of cards:

Avery8387_postcard-editscreen
[Fig. 4]

You can enter any static (unchanging) body text, images, etc. (and even undatable page number codes), on the card, leaving space for your specific merge fields (e.g., name, address, etc.) that you will enter below in Step 5. Or you can do it when you get to Step 5.

This Form will be used to produce the "front" of the cards. [The second time through this method it will be used to create the back of the cards, so your static text and merge fields will no doubt be different.]

Step 2. Select Tools, Merge, Form Document [button].

Merge_dialog
[Fig. 5]

Then -

Merge_dialog-2
[Fig. 6]

Click the "Create Form Document..." choice.

Merge_Data File Source
[Fig. 7]

Click the “Use file in active window” on the small "Data File Source" dialog that appears.

Click OK.


Step 3. Since this is the first time you are setting up a specific merge, the "Associate Form and Data" dialog appears.

The “Associate a data file” radio button should be active. If not, click that choice.

Associate Form and Data dialog
[Fig. 8]

Use the Bowse button on the field just to the right of that radio button to locate your original data file (for the first time through this method, it will be used to merge the front of the cards; for the second time through this method, choose the revised data file to merge the back of the cards). 

Click on
its name, and then click the Select button

Click OK to return to the Form document and the Merge dialog.


Step 4. In the Merge dialog ...

The Form document button should be set to Current Document.
The Data source button's field should show the data file you just selected in Step 3.
The Output button should be set to New Document. (You can use that document to print to ordinary paper to test the merge. Or use it to print a small range of cards.)

Merge_dialog-OptionsButtonChoice
[Fig. 9]

Click the Options button. The Merge Options dialog should be set to the defaults:

Merge Options dialog
[Fig. 10]

  - "Separate each..." should be checked
  - "Number of copies" = 1
  - "If field is empty in data source" set to "Remove Blank Line" 
  - "Display merge codes" set to "Show Codes"

Click the OK on that dialog to close it. Then -

Click the "X" or "Cancel" on the Merge dialog (you don't need it any more and your settings will be retained).

Step 5.  The 5-button Merge toolbar appears just above the document editing screen.

Merge toolbar
[Fig. 11]

Use the Insert Field button to Insert the merge fields where needed on the front of the cards (for the first merge in this method; for the second merge, Insert the fields needed for the back of the cards).

Then click Close to return to the document screen.

(You may also want to insert dates, merge codes, etc.  If so, see WordPerfect's Help for information about these features. Or see the Merge tips page.

From Doug's tutorial:

"You can set tabs for the [Form] in the Tab box [above the Merge property bar]. You can insert fields in the Form you are creating with the Insert Field... button. Unless you're doing something beyond the scope of this paper [i.e., creating merged address labels], you won't be using the Insert Merge Code, Go to Data, or Options buttons. You can play with them to see what they do without any harm done. The Merge... button reopens the Merge dialog we've been working with, and in which a Merge button (without an ellipsis) is clicked to actually perform a merge. You are now ready for [the next step]...")

Step 6.  Click the Merge button on the Merge toolbar. This brings up the Merge dialog again, with the same three buttons on the left (see Step 4).

Review the process so far:

The Form Document will obviously be the Current Document (since you already have it open), and the Output most likely will be to a New Document.  If you want the output sent directly to the printer (etc.) click the Output button. (This probably is best done after testing the Output on regular paper.)

The Data Source will be a file on your disc. Use the field on the right to confirm you are using your original data file (for the first merge run that prints the front of the cards), or your revised data file (for the second merge run that prints the back of the cards).

Then:

Merge dialog - Records button
[Fig. 12]

a.  Click the Records button, adjacent to the Data Source field.

Select Records dialog
[Fig. 13]

b.  Click the Mark records radio button on the Slect Records dialog.
c.  Click the Mark All Records in List button.

Important:

¤  If the first record listed in the window (currently pointed out in Fig. 13) is not a data record,
but instead it is a list of field names, uncheck (clear) the check box for the first record. You don't want this "record" to print because the first card must print with information from the first data record in the sequence of records. 

¤  Do not uncheck any other records. If you need to remove some records, you should do it in the original data file before you play the SwapRecs macro on it, and before you begin merging. Otherwise, the front and back of cards will become unsynchronized.

d.  Click OK to dismiss the Select Records dialog.

Merge dialog -with Merge button
[Fig. 14]

e.   Click Merge on the Merge dialog.

The result of the merge should show the front (or back, if this is the second merge) of all cards on the WordPerfect edit screen.

f.  Save the merged document (File, Save). Each merged output in this method should be named differently, perhaps with -front or -back in the filename.

This should end the merge run using this method.

Step 7.
Next ... repeat for the back (reverse) side of the cards ...

Repeat Steps 1-5 to create the Form for the back side of the cards, but be sure to choose (i.e., associate) the revised data file in Step 3.

Repeat Step 6 to merge the data to that Form, but be sure to choose (i.e., associate) the revised data file in Step 3 (and confirmed in Step 6).

Step 8.  Suggestion: Compare both merged output documents to see that the cards will print as expected.  An easy way to do this is compare the first two cards in each file, and the last two cards in each file. Are they correct?

Step 9.  Print the front and back of the cards using the appropriate merged files -or- by adjusting the Output on the Merge dialog.

- - - - -
Aug. 7, 2023 - Included in the ZIP file is an older, one-page document that gives instructions on how to create a merge Form for the front and back of 2-column cards, then merge/print using the two data files -- original and revised. The above Steps should be considered replacements for that document.