Spouses with different last names

K

Karen

Can't figure out how to direct Word to print labels in the following format:

Mr. and Mrs. John Smith (when both spouses have same last name) vs.

Mr. John Smith
Ms. Kathy Taylor (when spouses have different last names. )

Guessing I need an If statement, but can't figure it out.....

My data is set up with seperate fields for Courtesy Title, first name, last
name for the contact and spouse seperately, and an "extra" courtesy title
field for "Mr. and Mrs."

Please help! and thanks in advance
 
G

Graham Mayor

You need something like

{ IF { Mergefield SpouseLastName } <> "" "{ IF{ Mergefield LastName } <> {
Mergefield SpouseLastName } "{ Mergefield CourtesyTitle } { Mergefield
FirstName } { Mergefield LastName } & { Mergefield SpouseCourtesyTitle } {
Mergefield SpouseFirst Name} { Mergefield SpouseLastName }" "{ Mergefield
CourtesyTitle } & { Mergefield SpouseCourtesyTitle } { Mergefield
LastName }" }" "{ Mergefield CourtesyTitle } { Mergefield FirstName } {
Mergefield LastName}" }

You would need firstname lastname and courtesytitle for both principal and
spouse. The Mr & Mrs field is superfluous

The above should cater for single people as well as married people and
cohabitees.Change the field names as appropriate. Each pair of curly
brackets is inserted with CTRL+F9

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
T

Tami Daniels

I have these this code on my boards and I am having trouble getting it to work with word 2010.

My goal is to mail merge from an excel file on to labels in word. I have an excel file with First Name, Last Name, Spouse First and Spouse Last. I need code that will create lables for three scenarios:

1. Sally and John Doe
2. Adam Jones and Mary Smith
3. Bob Price

All the code seems to work great for number #1. Some work for #2. But most do not handle #3 correctly.

Can anyone help me?
 
L

Lisa Wilke-Thissen

Hi,
My goal is to mail merge from an excel file on to labels in word. I
have an excel file with First Name, Last Name, Spouse First and
Spouse Last. I need code that will create lables for three
scenarios:
1. Sally and John Doe
2. Adam Jones and Mary Smith
3. Bob Price

a simple solution would be to add a column STATUS to the Excel data
source. In this column you could insert "0" by using IF function, if
there is no spouse (Spouse First = empty), "1" if Spouse Last = Last
Name, "2" if Spouse Last <> Last Name.
So in the Word main document you can use the rule IF ... THEN ... ELSE:
If STATUS = 0 then Mergefield First Name, Mergefield Last Name,
otherwise
If STATUS = 1 then Mergefield First Name, and, Mergefield Spouse First,
Mergefield Last Name,
otherwise
Mergefield First Name, Mergefield Last Name, and, Mergefield Spouse
First, Mergefield Spouse Last.

If you don't want to use an addional Excel column, of course, you can
nest multiple conditions in Word, as shown in Graham's code.
The pair of curly brackets "{ }" always have to be inserted by pressing
Ctrl+F9. But I find it easier to use the "If ... then ... else" mail
merge rule, to make sure the correct syntax (brackets, spaces, quotes).
To nest multiple comparisons you can complete the first comparison, and
then set an asterisk where you cannot continue.
Afterwards, in the main document show the field codes by pressing Alt +
F9. Select the asterisk and call the "If ... then ... else" rule again.
This second rule will overwrite your asterisk, and so on.
Finally your code will be similar to Graham's code:

{ IF { Mergefield Spouse Last } <> ""
"{ IF{ Mergefield Last Name } <> { Mergefield Spouse Last }
"{ Mergefield First Name } { Mergefield Last Name } &
{ Mergefield Spouse First} { Mergefield Spouse Last }"
"{ IF Mergefield Last Name } = { Mergefield Spouse Last}
"{ Mergefield First Name } & { Mergefield Spouse First} { Mergefield
Last Name }"
"{ Mergefield First Name } { Mergefield Last Name }"}

Maybe, there are missing quotes and/or brackets. However, when using
the "If ... then ... else" rule, Word will insert those elements.
 

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