Group:  Microsoft Word » microsoft.public.word.mailmerge.fields
Thread: If statements

Geek News

If statements
dleo 10/27/2008 9:11:00 PM
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.
Re: If statements
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 10/27/2008 9:23:47 PM
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" <dleo[ at ]discussions.microsoft.com> wrote in message
news:A9F2741D-2BD6-4184-AFA8-391DEF2976B9[ at ]microsoft.com...
[Quoted Text]
> 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.


Re: If statements
dleo 10/27/2008 9:48:00 PM

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:

[Quoted Text]
> 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" <dleo[ at ]discussions.microsoft.com> wrote in message
> news:A9F2741D-2BD6-4184-AFA8-391DEF2976B9[ at ]microsoft.com...
> > 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.
>
>
>
Re: If statements
"Doug Robbins - Word MVP" <dkr[ at ]REMOVECAPSmvps.org> 10/28/2008 12:11:59 AM
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" <dleo[ at ]discussions.microsoft.com> wrote in message
news:9AF0355B-B36B-40F9-93FC-6E3286413ADD[ at ]microsoft.com...
[Quoted Text]
>
> 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" <dleo[ at ]discussions.microsoft.com> wrote in message
>> news:A9F2741D-2BD6-4184-AFA8-391DEF2976B9[ at ]microsoft.com...
>> > 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.
>>
>>
>>


Re: If statements
"macropod" <macropod[ at ]invalid.invalid> 10/28/2008 3:33:58 AM
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" <dkr[ at ]REMOVECAPSmvps.org> wrote in message news:uUNoPHJOJHA.240[ at ]TK2MSFTNGP03.phx.gbl...
[Quoted Text]
>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" <dleo[ at ]discussions.microsoft.com> wrote in message news:9AF0355B-B36B-40F9-93FC-6E3286413ADD[ at ]microsoft.com...
>>
>> 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" <dleo[ at ]discussions.microsoft.com> wrote in message
>>> news:A9F2741D-2BD6-4184-AFA8-391DEF2976B9[ at ]microsoft.com...
>>> > 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.
>>>
>>>
>>>
>
>

Re: If statements
dleo 10/28/2008 3:53:01 PM

Thank you macropod, your method is a lot easier. It works great!

Thanks again,
dleo

"macropod" wrote:

[Quoted Text]
> 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" <dkr[ at ]REMOVECAPSmvps.org> wrote in message news:uUNoPHJOJHA.240[ at ]TK2MSFTNGP03.phx.gbl...
> >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" <dleo[ at ]discussions.microsoft.com> wrote in message news:9AF0355B-B36B-40F9-93FC-6E3286413ADD[ at ]microsoft.com...
> >>
> >> 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" <dleo[ at ]discussions.microsoft.com> wrote in message
> >>> news:A9F2741D-2BD6-4184-AFA8-391DEF2976B9[ at ]microsoft.com...
> >>> > 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.
> >>>
> >>>
> >>>
> >
> >
>
>

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net