Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / August 2006

Tip: Looking for answers? Try searching our database.

Supress text if merge field is null

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Laura_Christian - 08 Aug 2006 01:11 GMT
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!
Peter Jamieson - 08 Aug 2006 03:46 GMT
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
> Hi there,
>
[quoted text clipped - 25 lines]
>
> Help!

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.