Mail merge with nested forms

K

KP

I have old wordperfect merge documents in which I need to convert to WORD but
am having trouble finding the correct commands to do so. Can anyone help or
steer me to documentation that can help with .

I have a conditional statement that looks at a data field to determine which
letter to merge. Then within the selected document I have conditions that
look at a data field to merge specific text from another. can this field look
at another lookup file?
Here are examples from Word perfect
If field (fieldname)='x' nestform(new merge doc1) else
If field (fieldname)='x' nestform(new merge doc2) else "Bad Data" endif
Next, within doc 1 & 2 there are mergefields that look at a code and need to
return a value from a different table look up file that inserts verbage
corresponding to code.
Thanks for any help!
 
P

Peter Jamieson

On the whole Word mailmerge is so different (and less powerful, as I
understand it) compared to WordPerfect merge that it's advisable to avoid
trying to translate, feature for feature. Better to try to understand what
Word can and cannot do, and redesign. FWIW I do not know of any articles
designed to help people porting from WP.
If field (fieldname)='x' nestform(new merge doc1) else
If field (fieldname)='x' nestform(new merge doc2) else "Bad Data" endif

In this case you /might/ be able to do something like

{ IF "{ MERGEFIELD whatever1 }" = "x"
"{ INCLUDETEXT "pathname of doc1.doc" }"
"{ IF "{ MERGEFIELD whatever2 }" = "x"
"{ INCLUDETEXT "pathname of doc2.doc" }"
"Bad Data" }" }

(Sorry, I don't know enough about WP merge to be sure.)

However, the included documents would not be "forms" in any sense usually
used in Word - just more text and fields, and only the document you actually
start the merge with is attached to a data source - you can't change sources
in the middle of the merge.
Next, within doc 1 & 2 there are mergefields that look at a code and need
to
return a value from a different table look up file that inserts verbage
corresponding to code.

Again, you can for example use INCLUDETEXT to include text from a boomarked
part of a document, so if you know that a bookmark named x (which yoiu can
set using a { SET } field contains abc, def or ghi, you can have bookmarks
abc, def, and ghi in a file called "c:\myincludes\i.doc" and use

{ INCLUDETEXT "c:\\myincludes\\i.doc" { REF x } }

to get the relevant chunk from i.doc. And so on...

Peter Jamieson
 
K

Kathy Webster

Ditto. I'm in the same predicament. WP merge commands are so wonderful and
powerful. I'm assuming there must be a way with Word commands or VB that
should be as powerful, if not moreso, than WP.

Can anyone point us in the right direction?
Kathy
 
P

Peter Jamieson

I'm assuming there must be a way with Word commands

Not really. Word's built-in merge features are limited in several important
ways, e.g.
a. you can only use one "data source". You can't switch data sources or
pull in new ones as you go along. You can INCLUDETEXT stuff, and you can use
DATABASE fields to pull in other material, but in quite limited ways.
b. that data source has got to have a tabular structure - the sort of thing
you would expect to retrieve as the result of any normal SQL query. It
can't, for example, be an XML file with lots of variations as to what can be
in each "record". It's as if its designers thought this kind of lmited
tabular data structure was the only format in town.
c. Word's "field language" suffers from many inconsistencies and other
shortcomings, some of which vary between versions of Word. As one example,
"automatic suppression of blank lines" where you have a blank field works
fine in Word 2000, but not in Word 2002/2003 if the field is embedded in
another field such as an IF or an INCLUDETEXT field; a construct such as {
IF condition "{ INCLUDETEXT something }" } may not work during a merge
whereas { INCLUDETEXT { IF condition "this file" "That file" } } generally
will.

There are, I think 3 ways you can attempt to control merge better:
d. use VBA to merge one record at a time. That lets you modify your main
document before processing each record, lets you output individual documents
for each data source record, and other stuff, while still using Word's data
source connection features to hide some of the nasty details of getting data
from different types of data source. You'll find examples of this kind of
thing in some of my messages in this group. However, you still have to pull
in your own data if you wanted more than one source, and in my experience it
is not simple to extend this method to situations where each document is
formed from multiple records in the data source.
e. use VBA with Word's Mail Merge events. This is the "official" way to do
(d), and has some advantages, but not a lot.
f. in essence, if you want /complete/ control over the merge, you have to
"roll your own merge" in VBA (or VB.NET/C#.NET, if that's your thing). You
do your own data connections, insert your own chunks of document for each
record or piece of data you want to process, and so on. Typically you should
probably avoid { MAILMERGE } fields and either insert data directly into the
document using VBA or use { DOCVARIABLE } fields to make it easier. But in
this case even more than the other two, you probably aren't going to be able
to let users maintain these applications themselves, unless you restrict
what they are allowed to do quite severely.

In Word 2003/2007 you can also consider developing an application that uses
code to generate WordML documents. However, in my view that is even more of
a "Programmer's" approach to the task. I tried some of this in WOrd 2003 and
it's pretty hard. It may be much simpler in Word 2007 with Visual
Studio.NET, but I really don't know.

Sorry I can't give you any useful links.

Peter Jamieson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top