Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Laura_Christian Laura_Christian is offline
external usenet poster
 
Posts: 1
Default Supress text if merge field is null

Hi there,

I'm having a hard time figuring out how to use if/then field codes in Word
for a mail merge.

In my address block, for instance, I would like to include the text "ATTN: "
at the beginning of the contact line if and only if a contact person has been
named in the Excel spreadsheet that is my data source. If no contact person
has been named, then the line should be suppressed altogether.

I tried the following code, but it did not work:

{IF {MERGEFIELD Firstname} "" "ATTN: {MERGEFIELD Firstname} {MERGEFIELD
LastName}" ""}

What am doing wrong? And can one just spell out the MERGEFIELD name, or do
you have to insert it some other way?

I'm having similar problems with commas that need to be inserted in the
address block if and only if a state has been named in the Excel spreadsheet;
with international addresses, there is usually no state, and so there should
not be a comma after the city name.

Help!


  #2   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Supress text if merge field is null

If you are using Word 2003 (and possibly 2002) you should try

{ MERGEFIELD Firstname \b "ATTN: " \f " " }{ MERGEFIELD Lastname \b " " }

and leave Word to remove blank lines where they are composed only of blank
fields and "white space".

What am doing wrong?


If you have to use an IF field, try:

{ IF "{ MERGEFIELD Firstname }" ""
"ATTN: {MERGEFIELD Firstname} " "" }{ MERGEFIELD LastName }

(you can put it all on one line)

All the {} need to be the special field code braces that you can insert
using ctrl-F9, not the ones you can insert as ordinary keyboard characters.
Everything else is plain text. If your field names have spaces in them, e.g.
are actually First name and Last Name, then you have to put double quotes
around them, e.g.

MERGEFIELD "First name" \b "ATTN: " \f " " }{ MERGEFIELD "Last Name" }

Peter Jamieson
"Laura_Christian" wrote in
message ...
Hi there,

I'm having a hard time figuring out how to use if/then field codes in Word
for a mail merge.

In my address block, for instance, I would like to include the text "ATTN:
"
at the beginning of the contact line if and only if a contact person has
been
named in the Excel spreadsheet that is my data source. If no contact
person
has been named, then the line should be suppressed altogether.

I tried the following code, but it did not work:

{IF {MERGEFIELD Firstname} "" "ATTN: {MERGEFIELD Firstname} {MERGEFIELD
LastName}" ""}

What am doing wrong? And can one just spell out the MERGEFIELD name, or do
you have to insert it some other way?

I'm having similar problems with commas that need to be inserted in the
address block if and only if a state has been named in the Excel
spreadsheet;
with international addresses, there is usually no state, and so there
should
not be a comma after the city name.

Help!




Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using IF to find whether a Merge Field contains a substring Joshua Pangborn Mailmerge 12 May 11th 23 02:51 AM
Creating dynamic cross reference links in a Word document torajudo Microsoft Word Help 5 April 27th 23 08:57 PM
Word applies direct format on File open Uriel Microsoft Word Help 16 November 27th 05 08:22 PM
merge instructions from text file Steve Mailmerge 8 November 26th 05 04:31 AM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 07:17 PM


All times are GMT +1. The time now is 09:43 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"