Conditional greeting line - informal when first name known, otherwise informal

J

John Williams

My mail merge list contains the following fields and records:

Title,FirstName,Surname
Mr,John,Williams
Mr,David,Smith
Mr,A.,Jones
Mr,,Cooper

For the first two records where the first name is known, I would like
the greeting to include just the first name, e.g. Dear John.

For the last two records where the first name isn't known (only
initials, or blank), I would like the greeting to be more formal, e.g.
Dear Mr Jones.

How can this be done using mailmerge fields?

Or is it easier to add a Greeting field to the mailing list and
manually add the appropriate greeting for each record?
 
C

Cindy M -WordMVP-

Hi John,

Which version of Word are we dealing with?
My mail merge list contains the following fields and records:

Title,FirstName,Surname
Mr,John,Williams
Mr,David,Smith
Mr,A.,Jones
Mr,,Cooper

For the first two records where the first name is known, I would like
the greeting to include just the first name, e.g. Dear John.

For the last two records where the first name isn't known (only
initials, or blank), I would like the greeting to be more formal, e.g.
Dear Mr Jones.

How can this be done using mailmerge fields?

Or is it easier to add a Greeting field to the mailing list and
manually add the appropriate greeting for each record?

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 
C

Cindy M -WordMVP-

Hi John,

Based on your description, and the fact that you have Word 2003, I'd say a
"Greeting line" would be what you need, combined with an IF field. This
works for me, in a quick test:

<<_AFTER_ ,>>" \l 2057 \e "Dear Sir or Madam,"
}{ GREETINGLINE \f "<<_BEFORE_ Dear >><<_FIRST0_>>
<<_AFTER_ ,>>" \l 2057
\e "Dear Sir or Madam," } }

I test if the "Mr." information is present. If it is, then the Greeting
line type for "Dear Mr. Jones" is displayed (the first one). If not, "Dear
John" (the second one) is displayed.

To create this, I first inserted the Greeting lines, select them both,
then pressed Ctrl+F9 to create the field brackets around them. Typed IF,
inserted the merge field, then typed the comparison. Alt+F9 toggles the
set of field codes on/off.
Word 2003.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

John Williams

Cindy M -WordMVP- said:
Hi John,

Based on your description, and the fact that you have Word 2003, I'd say a
"Greeting line" would be what you need, combined with an IF field. This
works for me, in a quick test:


<<_AFTER_ ,>>" \l 2057 \e "Dear Sir or Madam,"
}{ GREETINGLINE \f "<<_BEFORE_ Dear >><<_FIRST0_>>
<<_AFTER_ ,>>" \l 2057
\e "Dear Sir or Madam," } }

I test if the "Mr." information is present. If it is, then the Greeting
line type for "Dear Mr. Jones" is displayed (the first one). If not, "Dear
John" (the second one) is displayed.

Cindy,

Thanks for you help, although I couldn't get your code to display the
"Dear John" variant. Based on your help, I came up with:

{ IF { MERGEFIELD "FirstName" }{ GREETINGLINE \f "<<_BEFORE_ Dear
This works for all cases, except where the first name is an initial
(e.g. A.) where it displays "Dear A." and should display Dear Mr
Jones. Unfortunately there doesn't seem to be a way of checking
whether a mergefield contains '.'.

PS - How do you copy and paste the merge code displayed by Alt+F9? I
can copy the code, but the result of the merge is pasted, not the code
itself.
 
C

Cindy M -WordMVP-

Hi John,
How do you copy and paste the merge code displayed by Alt+F9? I
can copy the code, but the result of the merge is pasted, not the code
itself.
I use a macro. You should find it somewhere on my website, Mail merge
FAQ, Tips'n'Tricks, under Working with Word fields.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :)
 

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