Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Is there a way to use IF statements within a mail merge? I'm using an excel
file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Use the follwing field construction
{ IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD FirstName }" "{ MERGEFIELD FirstName } } You may need to change the Prefix and FirstName to the actual names of your fields. You must use Ctrl+F9 to insert each pair of field delimiters { } and you use Alt+F9 to toggle off their display. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... Is there a way to use IF statements within a mail merge? I'm using an excel file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]() It didn't work. Well, the data merges successfully, but there is no space in front of the first name no matter if there is a prefix or not. Also, my first name field is 2 words (FIRST NAME) so maybe that has something to do with it. "Doug Robbins - Word MVP" wrote: Use the follwing field construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD FirstName }" "{ MERGEFIELD FirstName } } You may need to change the Prefix and FirstName to the actual names of your fields. You must use Ctrl+F9 to insert each pair of field delimiters { } and you use Alt+F9 to toggle off their display. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... Is there a way to use IF statements within a mail merge? I'm using an excel file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I missed a closing quote when typing the construction
{ IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD "First_Name" }" "{ MERGEFIELD "First_Name" }" } If the name of the field that contains the first name is two words,. use the construction as shown above. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... It didn't work. Well, the data merges successfully, but there is no space in front of the first name no matter if there is a prefix or not. Also, my first name field is 2 words (FIRST NAME) so maybe that has something to do with it. "Doug Robbins - Word MVP" wrote: Use the follwing field construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD FirstName }" "{ MERGEFIELD FirstName } } You may need to change the Prefix and FirstName to the actual names of your fields. You must use Ctrl+F9 to insert each pair of field delimiters { } and you use Alt+F9 to toggle off their display. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... Is there a way to use IF statements within a mail merge? I'm using an excel file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
#5
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Hi Doug,
I'd be inclined to use a simpler construction: {IF{MERGEFIELD Prefix} "" "{MERGEFIELD Prefix} "}{MERGEFIELD "First_Name"} For the OP, the steps to reproduce this would be: .. copy your «Prefix» field and paste it into your document ahead of the «First_Name» field, thus - «Prefix»«Prefix»«First_Name»; .. select the two «Prefix» fields and press Ctrl-F9 to enclose them in a new field, thus - {«Prefix»«Prefix»}«First_Name»; .. fill in around the new field braces thus, paying careful attention to the spacing - {IF«Prefix» "" "«Prefix» "}«First_Name»; .. position the cursor anywhere in this field and press F9 to update it; .. run the mailmerge. -- Cheers macropod [MVP - Microsoft Word] "Doug Robbins - Word MVP" wrote in message ... I missed a closing quote when typing the construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD "First_Name" }" "{ MERGEFIELD "First_Name" }" } If the name of the field that contains the first name is two words,. use the construction as shown above. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... It didn't work. Well, the data merges successfully, but there is no space in front of the first name no matter if there is a prefix or not. Also, my first name field is 2 words (FIRST NAME) so maybe that has something to do with it. "Doug Robbins - Word MVP" wrote: Use the follwing field construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD FirstName }" "{ MERGEFIELD FirstName } } You may need to change the Prefix and FirstName to the actual names of your fields. You must use Ctrl+F9 to insert each pair of field delimiters { } and you use Alt+F9 to toggle off their display. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... Is there a way to use IF statements within a mail merge? I'm using an excel file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
#6
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]() Thank you macropod, your method is a lot easier. It works great! Thanks again, dleo "macropod" wrote: Hi Doug, I'd be inclined to use a simpler construction: {IF{MERGEFIELD Prefix} "" "{MERGEFIELD Prefix} "}{MERGEFIELD "First_Name"} For the OP, the steps to reproduce this would be: .. copy your «Prefix» field and paste it into your document ahead of the «First_Name» field, thus - «Prefix»«Prefix»«First_Name»; .. select the two «Prefix» fields and press Ctrl-F9 to enclose them in a new field, thus - {«Prefix»«Prefix»}«First_Name»; .. fill in around the new field braces thus, paying careful attention to the spacing - {IF«Prefix» "" "«Prefix» "}«First_Name»; .. position the cursor anywhere in this field and press F9 to update it; .. run the mailmerge. -- Cheers macropod [MVP - Microsoft Word] "Doug Robbins - Word MVP" wrote in message ... I missed a closing quote when typing the construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD "First_Name" }" "{ MERGEFIELD "First_Name" }" } If the name of the field that contains the first name is two words,. use the construction as shown above. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... It didn't work. Well, the data merges successfully, but there is no space in front of the first name no matter if there is a prefix or not. Also, my first name field is 2 words (FIRST NAME) so maybe that has something to do with it. "Doug Robbins - Word MVP" wrote: Use the follwing field construction { IF { MERGEFIELD Prefix } "" "{ MERGEFIELD Prefix } { MERGEFIELD FirstName }" "{ MERGEFIELD FirstName } } You may need to change the Prefix and FirstName to the actual names of your fields. You must use Ctrl+F9 to insert each pair of field delimiters { } and you use Alt+F9 to toggle off their display. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "dleo" wrote in message ... Is there a way to use IF statements within a mail merge? I'm using an excel file as my data source. I have the prefix merge field, but about half of the data entries have none. So when I merge in Word, the prefix field is skipped (as it should), but I still get that space in between where the prefix would go and the person's first name. Is there some sort of IF field where I could basically say "if there IS a prefix put in the space, but if there isn't, don't put a space." I hope that makes sense. |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
If then statements | Mailmerge | |||
IF statements not working | Mailmerge | |||
limits on if statements | Mailmerge | |||
IF Statements and REF Fields | Microsoft Word Help | |||
financial statements | Microsoft Word Help |