View Single Post
  #4   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Mergefields, IF statements and section breaks

The point of the exercise was that you don't need the conditional
statements. The Includetext field inserts the appropriate document. And yes
you can put mergefields in the included documents and they will work
provided they match the fields in your data source.

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



JAnderson wrote:
Hmm... So could I still use conditional statements with INCLUDETEXT?
If my database record is 'zebra', I only want my zebra document to
show.

Also, would includetext retain formatting? It's important that I keep
margins, footers, and text formatting in a certain way.

Lastly, can INCLUDETEXT also accommodate mergefields? For example,
inside my zebra document are mergefields like 'zoo name' 'zoo
address' 'zoo city', etc., which merge from my database. This works
inside IF statements, but I wonder if it would with INCLUDETEXT...

Thanks,

"macropod" wrote:

Hi JAnderson,

You'd probably get better results by creating a separate reference
document for each scenario, then embedding your MERGEFIELD within an
INCLUDETEXT field pointing to the folder where those documents can
be found.

For example, suppose your refrence documents are in the folder C:\My
Documents\Animals and you have a series of files (eg Bear.doc,
Zebra.doc, etc) in that folder. In that case you could use an
INCLUDETEXT field coded as: {INCLUDETEXT "C:\\My
Documents\\Animals\\{MERGEFIELD ANIMAL}.doc"}

Now, if you add a new 'Animal' to your database, all you need to do
is to create a corresponding reference document for it in the folder
C:\My Documents\Animals.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message
news
Ok, this is a somewhat complicated one, so bear with me:

I have a large document where each page is an "IF" statement
followed by a next-page section break. Let's pretend that I'm
using the merge field "Animal" as my condition:

{IF{MERGEFIELD_ANIMAL}= "BEAR" "
Document relating to bears
More text, formatting of 0.5" margins
More text
---section break (next page)---
" ""}
{IF{MERGEFIELD_ANIMAL}= "ZEBRA" "
Document relating to zebras
More text, formatting of 1" margins
More text
---section break (next page)---
" ""}
BEGIN REGULAR 2-PAGE DOCUMENT
More text, 1.2" margins
More text
End of document

Thus, if the condition "Bear" is met, then a document relating to
bears will become part of my document, otherwise, nothing happens
(the false condition is ""). Likewise, if "Zebra" is the value of
the field, then a document about zebras appears. Under any
condition, however, my "regular" document is always part of the
merge (say, a fact sheet about zoo animals).

This method, while potentially inelegant, works for our specific
needs, and works without any problems. However, there becomes a
point where inserting one more "IF" statement will "break" the
whole document.

Say I realize that I need to add yet another document about Lions,
so I follow the formatting above and enter this Lion IF statement
right after the zebra IF statement. For some reason, headers,
footers and margins (section break qualities) will not be correct
for whatever document I merge, and sometimes the "next page"
section breaks will reorient themselves as "continuous", thus
melding pages together.

I'm a bit stuck at this point, because I can't understand why, if a
section break is within an IF statement, it would later become
functional even though its condition is not met. Would it be more
effective if, every time I added a new IF statement, I re-built the
whole document starting with "Bear", then "Zebra", then "Lion",
then "Regular document"? Is this just a lost cause?

(The reason I am insistent on doing it this way is because, on a
grander scale, I do not want to have hundreds of individual
documents to use for merging data; I would prefer to have one
'master' document.)

Thanks in advance,