ACC: Exporting WordPerfect Secondary Files to Microsoft Access

ID: Q99317


The information in this article applies to:


SUMMARY

Moderate: Requires basic macro, coding, and interoperability skills.

This article describes how to export data from a WordPerfect (WP) print merge secondary file (or data file) to Microsoft Access.


MORE INFORMATION

A WordPerfect secondary file (or data file) contains records, typically names and addresses, used in a print merge with a primary file (or form file), such as a form letter or mailing label document. To use data from a secondary file, the information must be saved in a comma or tab delimited (separated), unformatted text file. WordPerfect secondary files are neither comma nor tab delimited.

A typical comma delimited text file resembles the following:


   "Joe","Smith","123 Main Street","Seattle, WA 98033"
   "Martha","Jones","4523 Williams Ave","","Redmond, WA 98052" 

The equivalent WordPerfect secondary file resembles the following:

   Joe{END FIELD}
   Smith{END FIELD}
   123 Main Street{END FIELD}
   Seattle, WA 98033{END FIELD}
   {END RECORD}
   <CRLF>
   Martha{END FIELD}
   Jones{END FIELD}
   4523 Williams Ave{END FIELD}
   {END FIELD}
   Redmond, WA 98052{END FIELD}
   {END RECORD}
   <CRLF> 

where <CRLF> represents a hard page break. Note also that in Wordperfect versions later than 5.1, {END FIELD} and {END RECORD} will be shown as boldface without braces.

Problems: Secondary Files With Multiple-Line Field Entries

WordPerfect allows you to merge multiple lines of data in a single field. The following record has only two fields:

   Joe Smith{END FIELD}
   123 Main Street
   Suite 101
   Seattle, WA 98033{END FIELD}
   {END RECORD}
   <CRLF> 

Delimited text files use carriage returns to mark the end of a record; these cannot be included in the field information. Each line in the secondary file must be made a unique field before it can be prepared as a delimited file. When you add the {END FIELD} code to a record, the new field is represented in every record in your file. Each record must contain the same number of fields and each field should either contain the same type of data or remain empty.

Using the {FIELD NAMES} Section in a Secondary File

Fields in a secondary file can be referenced from a primary file by number. These fields are numbered from top to bottom, or by a name that is assigned in the optional {FIELD NAMES} section, which appears at the top of the secondary file. The {FIELD NAMES} section in WP 5.1 may look like this

   {FIELD NAMES}
   Name~
   Address~
   ~{END RECORD} 

or like this:

   {FIELD NAMES}Name~Address~~{END RECORD} 

The {FIELD NAMES} section in WP versions later than 5.1 may look like this:

   FIELDNAMES(Name;Address)ENDRECORD 

If referenced by number, the Name field is 1 and the Address field is 2. A hard page break falls between this section and the first record.

Preparing the Comma Delimited Secondary File

WordPerfect for Windows:

WordPerfect for Windows can save secondary files directly in a comma delimited format. However, if you have a {FIELD NAMES} section in the file and want to preserve these names in Microsoft Access, you must reformat the file so that each name is separated by a comma and not by a tilde (~) character. Also, the fields should not appear on separate lines, nor be followed by carriage returns. The following {FIELD NAMES} section

   {FIELD NAMES}
   Name~
   Address~
   Phone~
   ~{END RECORD} 

should be edited as follows:

   {FIELD NAMES}Name,Address,Phone{END RECORD} 

Creating the Comma Delimited File:
  1. From the File menu, choose Save As.


  2. In the Save As box, type a unique file name, preferably with a .TXT extension.


  3. In the Format box, select ASCII Delimited Text (DOS), then choose Save.


WordPerfect for MS-DOS:

WordPerfect for MS-DOS cannot save secondary files directly in a delimited format. To create the comma delimited file, you need to create a primary file (or form file) and merge the secondary information into it. The primary document will contain fields already in comma delimited format. Once the data is merged, remove the hard page breaks separating each record. The resulting document can be saved as a text file that Microsoft Access can import.

Creating the Primary File (or form file) in WP 5.1:
  1. Press F7, choose No, then choose No again to create a new WordPerfect document.


  2. Type an opening quotation mark. Press SHIFT+F9, then 1 (Field).


  3. In the Enter Field box, type the name of the first field if a {FIELD NAMES} section appears in the secondary file, or type "1" if there is no {FIELD NAMES} section.


  4. Press ENTER. Type a closing quotation mark, followed by a comma.


  5. Repeat steps 2-4 for each field in the secondary file, changing only the field name or field position number as appropriate. Do not type a comma after the last field.


  6. Press ENTER to place a hard carriage return at the end of the record.


  7. Press F10, type a unique filename in the Document To Be Saved box, and press ENTER. The primary document in WP 5.1 will resemble the following:

    "{FIELD}name~","{FIELD}address~","{FIELD}phone~"


Creating the Primary File (or form file) in WP 6.0:
  1. Press F7, choose No, then choose No again to create a new WordPerfect document.


  2. Type an opening quotation mark. Press SHIFT+F9, then 1 (Form).


  3. Choose 1 (Field). Type the name of the first field and choose OK; or choose List Field Names to select fields from an existing data file.


  4. Type a closing quotation mark, followed by a comma.


  5. Repeat steps 2-4 for each field in the secondary file, changing only the field name or field position number as appropriate. Do not type a comma after the last field.


  6. Press ENTER to place a hard carriage return at the end of the record.


  7. Press F10, type a unique filename in the Document To Be Saved box, and press ENTER. The form document in WP 6.0 will resemble the following:

    "FIELD(name)","FIELD(address)"

    NOTE: It is acceptable for the lines to wrap on the screen.


Merging the Primary and Secondary Files:
  1. Press F7, choose No, then choose No again to create a new WordPerfect document.


  2. Press CTRL+F9, then 1 (Merge).


  3. In the Primary File or Form File box, type the name of the primary file and press ENTER.


  4. In the Secondary File or Data File box, type name of the secondary file and press ENTER.


  5. For WP 6.0 only, choose Merge.


Removing the Residual Hard Page Breaks:
  1. In WP 5.1, press ALT+F2, then N to disallow replacements. In WP 6.0, press ALT+F2.


  2. At the -> Srch prompt, press CTRL+ENTER to enter a [HPg] code.


  3. Press ALT+F2 twice to pass the Replace With message.


Saving As an Unformatted Text File in WP 5.1:
  1. Press CTRL+F5, then 1 (DOS Text), then 1 (Save).


  2. Type a valid document name, preferably with a .TXT extension, and press ENTER.


Saving As an Unformatted Text File in WP 6.0:
  1. Press F10, type a valid document name, preferably with a .TXT extension.


  2. Press TAB, choose DOS Delimited Text, then press ENTER.


WordPerfect is manufactured by WordPerfect Corporation, a vendor independent of Microsoft; we make no warranty, implied or otherwise, regarding this product's performance or reliability.


REFERENCES

"WordPerfect for DOS Reference," version 5.1, pages 420-431

"WordPerfect for DOS Workbook," version 5.1, pages 237-246

"WordPerfect for Windows Reference," version 5.1, pages 300-308

"WordPerfect for Windows Workbook," version 5.1, pages 203-210

"WordPerfect for Windows Reference," version 5.2, pages 321-328

"WordPerfect for Windows Workbook," version 5.2, pages 227-236

"WordPerfect for DOS Reference," version 6.0, pages 412-422

"WordPerfect for DOS Learning WordPerfect," version 6.0, pages 195-204

"WordPerfect for Windows Reference," version 6.0, pages 453-473

"WordPerfect for Windows Learning WordPerfect," version 6.0, pages 201-210


Keywords          : kb3rdparty kbinterop 
Version           : 1.0 1.1 2.0 7.0 97
Platform          : WINDOWS 
Issue type        : kbinfo 

Last Reviewed: March 22, 1999