View Single Post
  #10   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Peter Jamieson Peter Jamieson is offline
external usenet poster
 
Posts: 4,582
Default Word mailmerge how to do multiple If statements

I've now had another look at this on Word 2000 SP3 (not fully patched
though) and the current patched version of Word 2003.

Using relatively simple tests (i.e. may not be the whole story):
a. the behaviour is the same in both versions
b. the print and the preview are the same on both versions, but the results
when merging to a new document are different
c. for fields inside an INCLUDETEXT, the technique described in my previous
post consistently achieves suppression on both versions of Word, i.e. unless
someone knows a better way, it's the way to go.

{ IF "{ MERGEFIELD myfield1 }" = ""
"" "{ MERGEFIELD myfield1 }
" }{ IF "{ MERGEFIELD myfield2 }" = ""
"" "{ MERGEFIELD myfield2 }
" }

d. MERGEFIELDs inside an IF /in the main document/ (e.g.

{ IF 1 = 1 "{ MERGEFIELD a }
{ MERGEFIELD b }" "" }

are never suppressed

e. When you merge to a new document, there is a difference between the
behaviour of an INCLUDETEXT that is nested in an IF in the main document,
and an INCLUDETEXT that is not nested:

The result of an { INCLUDETEXT "pathname" } is that
1. the INCLUDETEXT is retained
2. fields are not suppressed
3. the output document looks the same as the preview and printed version

The result of an { IF 1 = 1 "{ INCLUDETEXT "pathname" }" "" } is that
4. the INCLUDETEXT is resolved
5. fields are suppressed, as long as they are not also nested inside an IF
inside the INCLUETEXTed document
6. the output document may therefore not look like the preview and printed
version.

Peter Jamieson

"Peter Jamieson" wrote in message
...
FYI blank line suppression does not work with fields nested in other
fields (such as INCLUDETEXT, IF) in Word 2002/2003. Or at least some
versions of it. Although I think it did work with Word 2000,
a. I probably mostly merged to new documents, not the printer
b. various aspects of field behaviour have been changed with service packs
and security updates in Word 2000. This /could/ be one of them. If so, it
could be that the only way you will get these fields to function correctly
is to use the other, more complex technique of inserting blank lines when
the fields are not empty, e.g.

{ IF "{ MERGEFIELD myfield1 }" = ""
"" "{ MERGEFIELD myfield1 }
" }{ IF "{ MERGEFIELD myfield2 }" = ""
"" "{ MERGEFIELD myfield2 }
" }

I'm not sure I can get at my Word 2000 system right now but when I can
I'll take a look. Which Word SR/SP are you using?

Peter Jamieson

"Peter" wrote in message
...
Thanks again Ed.

Really appreciate all your advice!

I am using Ver 2000.

I have tried various things you have mentioned, but no luck. The code I
have
I initially set with information from Microsoft, combined with your
initial
suggestions. I have a link to a screen shot I took of the code I am
using. I
did try keying in the code as you showed Pearl but the documents would
not
come up. The code in the link gives me the documents, just will not
supress
blank lines unless I merge to a new document.

http://img.photobucket.com/albums/v2...g?t=1177710767

Thanks again . . .

Peter