0
votes

I am working with a large number of .frm and .wpd WordPerfect files and I am trying to convert them to .docx while retaining all of the mail-merge logic.

Saving the files as .docx within WordPerfect X6 or opening the .frm/.wpd files from within Word 2016 both result in a complete loss of the mail-merge codes.

Is there any way to convert the WordPerfect files so that they retain similar merge functionality in the .docx format?

1
You need to ask this in an end-user forum, such as SuperUser or Microsoft Answers, I believe...Cindy Meister
I am open to implementing a programatic solution if writing a parser to convert the mail-merge syntax is possibleMike
Then your question is too broad for StackOverflow. Been a long time since I've looked at WordPerfect (in the DOS days I did a lot of mail merge with it). From what I recall it uses a very different approach which hardly converts directly to Word except in the most simple cases. End-user folks are more likely conversant with how things differ and how you have to approach converting from WP to Word. Once you know the logic, then you start looking at what can be done programmatically.Cindy Meister

1 Answers

1
votes

Here is a somewhat crazy approach:

Use WP_Reader to parse the document.

Collect all the pertinent merge functions (there are a bunch of merge commands, and you will have to figure out which ones you need to translate into Word merge fields).

Make a dictionary that translates each needed merge function into its WP string "code" (for searching purposes).

Write a simple WordPerfect macro that uses a passed-in variable to search and replace each merge "code" with a unique text marker.

Open the document using the WordPerfect.PerfectScript interface.

Use the PerfectFit.PerfectScript interface to call the WP macro and pass in each merge function you want replaced with its unique marker. You can't make a .NET call to a WordPerfect document to search for anything that is not ASCII text, so you are forced to use a macro and PerfectFit to do this (thanks, Corel!).

Save the wpd document as a Word document (or probably safer, use Office Interop to do this).

Use the Office Interop commands to find each unique marker and replace it with a new merge field (I'm a little fuzzy about how this part works).

This approach comes with a few caveats:

WP_Reader in its current form does not model any merge functions. This will take a bit of coding, but the approach is pretty straightforward. I'm the only person working on this project, and have not yet had a need for these functions. All of the merge functions either have no parameters or 1 or more strings. These functions should be easy to model, and I can help you get started.

.frm and .dat files are really WordPerfect files that are set up as merge documents and data sources for merge documents (maybe they are used for other purposes, too). You can use WP_Reader to model those files the same as .wpd files.

This approach will only work if you have extremely simple merge documents. The WordPerfect merge arena includes its own language, separate from the WP command set. There are If statements, For loops, etc, that would not translate into anything useful in a Word document.

Before you try this time-consuming project, see if LibreOffice converts wpd files with merge codes directly into the .odt format. The lib-wpd project, which is a built-in program in LibreOffice, has been running since 2003 or so, and they might have already incorporated this functionality. Converting from .odt to .docx should be easy to do.