Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Where can I find help using nested if...then fields in merge docs
I have an Excel spreadsheet I am using as a database (as it has less thatn
100 records, Excel is adequate). I have 3 types of mail targets - with variations 1. Unmarried clients with and without middle initials 2. Married clients with shared surname, with and without middle initials 3. Married clients with different surnames, with and without middle initials My field names are First_Name1, Mid_Init1, Last_Name1, First_Name2, Mid_Init2, and Last_Name2. I need to set up my mail merge such that it gives me: First_Name1 Mid_Init1 If First_Name2 is blank, return First_Name1 Mid_Init1 Last_Name1 (i.e. John J. Doe) If First_Name2 is not blank and Last_Name2 is blank, return First_Name1 Mid_Init1 and First_Name2 Mid_Init2 Last_Name1 (I.e. John J. and Jane K. Doe) If Last_Name2 is not blank, return First_Name1 Mid_Init1 Last_Name1 and First_Name2 Mid_Init2 Last_Name2 I tried using nested if combined with .AND. but it doesn't seem to work. Anyone have an idea on this? |
#2
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Where can I find help using nested if...then fields in merge docs
Graham Mayor's page at
http://www.gmayor.com/formatting_word_fields.htm has a section titled "Insert field information and associated text conditionally" that shows how to construct this kind of thing. In this case you probably need something like the following, assuming that Mid_Init1 and Mid_Init2 could also be blank { MERGEFIELD First_Name1 }{ IF "{ MERGEFIELD Mid_Init1 }" = "" "" " { MERGEFIELD Mid_Init1 }" }{ IF "{ MERGEFIELD First_Name2 }" = "" " { MERGEFIELD Last_Name1 )" "{ IF "{ MERGEFIELD Last_Name2 }" = "" " and { MERGEFIELD First_Name2 }{ IF "{ MERGEFIELD Mid_Init2 }" = "" "" " { MERGEFIELD Mid_Init2 }" } { MERGEFIELD Last_Name1 }" " { MERGEFIELD Last_Name1 } and { MERGEFIELD First_Name2 }{ IF "{ MERGEFIELD Mid_Init2 }" = "" "" " { MERGEFIELD Mid_Init2 }" } { MERGEFIELD Last_Name2 }" } } The layout doesn't have to be the way i've show it (it's difficult to show the structure well) but all the {} need to be the special field code braces you can insert using ctrl-F9 and pay attention to the spacing! You can sometimes simplify stuff in Word 2003 and maybe 2002 using \b and \f switches to insert text before or following the field when it is non-blank, e.g. { MERGEFIELD First_Name1 }{ MERGEFIELD Mid_Init1 \b " " }{ IF "{ MERGEFIELD First_Name2 }" = "" " { MERGEFIELD Last_Name1 )" "{ IF "{ MERGEFIELD Last_Name2 }" = "" " and { MERGEFIELD First_Name2 }{ MERGEFIELD Mid_Init2 \b " " } { MERGEFIELD Last_Name1 }" " { MERGEFIELD Last_Name1 } and { MERGEFIELD First_Name2 }{ MERGEFIELD Mid_Init2 \b " " } { MERGEFIELD Last_Name2 }" } } Peter Jamieson "JVRB" wrote in message ... I have an Excel spreadsheet I am using as a database (as it has less thatn 100 records, Excel is adequate). I have 3 types of mail targets - with variations 1. Unmarried clients with and without middle initials 2. Married clients with shared surname, with and without middle initials 3. Married clients with different surnames, with and without middle initials My field names are First_Name1, Mid_Init1, Last_Name1, First_Name2, Mid_Init2, and Last_Name2. I need to set up my mail merge such that it gives me: First_Name1 Mid_Init1 If First_Name2 is blank, return First_Name1 Mid_Init1 Last_Name1 (i.e. John J. Doe) If First_Name2 is not blank and Last_Name2 is blank, return First_Name1 Mid_Init1 and First_Name2 Mid_Init2 Last_Name1 (I.e. John J. and Jane K. Doe) If Last_Name2 is not blank, return First_Name1 Mid_Init1 Last_Name1 and First_Name2 Mid_Init2 Last_Name2 I tried using nested if combined with .AND. but it doesn't seem to work. Anyone have an idea on this? |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2003: Insert Merge Fields window | Mailmerge | |||
MS Word form fields versus mail merge fields | Mailmerge | |||
Form fields versus mail merge fields | Microsoft Word Help | |||
Can't find locked fields | Mailmerge | |||
Using MAILMERGE fields within HYPERLINK fields for Merge to Email | Mailmerge |