A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Word » Mailmerge
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Mergefields, IF statements and section breaks



 
 
Thread Tools Display Modes
  #1  
Old July 16th, 2008, 05:26 PM posted to microsoft.public.word.mailmerge.fields
JAnderson
external usenet poster
 
Posts: 26
Default Mergefields, IF statements and section breaks

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,
  #2  
Old July 16th, 2008, 11:08 PM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Mergefields, IF statements and section breaks

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,


  #3  
Old July 16th, 2008, 11:29 PM posted to microsoft.public.word.mailmerge.fields
JAnderson
external usenet poster
 
Posts: 26
Default Mergefields, IF statements and section breaks

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,



  #4  
Old July 17th, 2008, 06:57 AM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
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,



  #5  
Old July 17th, 2008, 08:37 PM posted to microsoft.public.word.mailmerge.fields
JAnderson
external usenet poster
 
Posts: 26
Default Mergefields, IF statements and section breaks

Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,




  #6  
Old July 17th, 2008, 11:31 PM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Mergefields, IF statements and section breaks

Hi JAnderson,

I think you'll get the results you're after if you make the first character of each of the 'animal' documents a continuous Section
break and if you insert a continuous Section break in your mailmerge document after the mergefields also. Alternatively, if you want
each of the 'animal' documents to start on a new page, and the mailmerge document to resume on a new page after that, make the
section breaks 'next page'.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,





  #7  
Old July 18th, 2008, 07:01 PM posted to microsoft.public.word.mailmerge.fields
JAnderson
external usenet poster
 
Posts: 26
Default Mergefields, IF statements and section breaks

Ok, we're definitely getting closer - thank you! I did what you suggested by
placing a continuous section break at the beginning of my 'animal' documents,
and placed a section break after my INCLUDETEXT field.

Two problems:

1) Some of my 'animal' documents have multiple section breaks within the
document (separate footers, etc.). I'm not sure how this is affecting the
resulting document.

2) My resulting merged document only retains the correct formatting for the
first page, then reverts to the default formatting of the 'primary/host'
document. Furthermore, all text and headers/footers are shifted partially
off the visible area of the page (these are not unusual documents, just text
and some tables within the printable margins of a page).

I'm encouraged by the results so far; I really want to get to the point
where my INCLUDETEXT field can LITERALLY pull the entire document. All
mergefields within the INCLUDETEXT document are merging correctly, thankfully.

Any ideas why the formatting doesn't 'stick' on these documents? What about
adding a field switch to the INCLUDETEXT field, like *Charformat or something?

"macropod" wrote:

Hi JAnderson,

I think you'll get the results you're after if you make the first character of each of the 'animal' documents a continuous Section
break and if you insert a continuous Section break in your mailmerge document after the mergefields also. Alternatively, if you want
each of the 'animal' documents to start on a new page, and the mailmerge document to resume on a new page after that, make the
section breaks 'next page'.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,





  #8  
Old July 18th, 2008, 11:16 PM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Mergefields, IF statements and section breaks

Hi JAnderson,

Provided your:
.. source document (ie the one referenced by the INCLUDETEXT field) starts off with a Section break; and
.. target document (ie your mailmerge main document) has a Section break after the mergefields,
I don't believe the Section breaks in the source document will have any effect on the target document outside of those Section
breaks.

As for the partial shifting, are you sure the source and target documents have the same page formats (eg A4)?

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ok, we're definitely getting closer - thank you! I did what you suggested by
placing a continuous section break at the beginning of my 'animal' documents,
and placed a section break after my INCLUDETEXT field.

Two problems:

1) Some of my 'animal' documents have multiple section breaks within the
document (separate footers, etc.). I'm not sure how this is affecting the
resulting document.

2) My resulting merged document only retains the correct formatting for the
first page, then reverts to the default formatting of the 'primary/host'
document. Furthermore, all text and headers/footers are shifted partially
off the visible area of the page (these are not unusual documents, just text
and some tables within the printable margins of a page).

I'm encouraged by the results so far; I really want to get to the point
where my INCLUDETEXT field can LITERALLY pull the entire document. All
mergefields within the INCLUDETEXT document are merging correctly, thankfully.

Any ideas why the formatting doesn't 'stick' on these documents? What about
adding a field switch to the INCLUDETEXT field, like *Charformat or something?

"macropod" wrote:

Hi JAnderson,

I think you'll get the results you're after if you make the first character of each of the 'animal' documents a continuous
Section
break and if you insert a continuous Section break in your mailmerge document after the mergefields also. Alternatively, if you
want
each of the 'animal' documents to start on a new page, and the mailmerge document to resume on a new page after that, make the
section breaks 'next page'.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,






  #9  
Old July 19th, 2008, 12:16 AM posted to microsoft.public.word.mailmerge.fields
JAnderson
external usenet poster
 
Posts: 26
Default Mergefields, IF statements and section breaks

From what you're describing, what I'm doing should work perfectly, you're
right. The best way I can describe what is going on is that only the first
page of my final product seems to observe the formatting; all remaining pages
revert to the target document's default settings. Furthermore, the text from
the source document does not line up with the indent arrows - instead it
falls off to the left of the page. It's very unusual. The same thing
happens with the header and footer on all pages after the first page.

Do you think I should try a section break at the beginning AND end of the
source documents? I'm SO close, I feel like I'm just missing one step.

Thanks again for all of your help,


"macropod" wrote:

Hi JAnderson,

Provided your:
.. source document (ie the one referenced by the INCLUDETEXT field) starts off with a Section break; and
.. target document (ie your mailmerge main document) has a Section break after the mergefields,
I don't believe the Section breaks in the source document will have any effect on the target document outside of those Section
breaks.

As for the partial shifting, are you sure the source and target documents have the same page formats (eg A4)?

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ok, we're definitely getting closer - thank you! I did what you suggested by
placing a continuous section break at the beginning of my 'animal' documents,
and placed a section break after my INCLUDETEXT field.

Two problems:

1) Some of my 'animal' documents have multiple section breaks within the
document (separate footers, etc.). I'm not sure how this is affecting the
resulting document.

2) My resulting merged document only retains the correct formatting for the
first page, then reverts to the default formatting of the 'primary/host'
document. Furthermore, all text and headers/footers are shifted partially
off the visible area of the page (these are not unusual documents, just text
and some tables within the printable margins of a page).

I'm encouraged by the results so far; I really want to get to the point
where my INCLUDETEXT field can LITERALLY pull the entire document. All
mergefields within the INCLUDETEXT document are merging correctly, thankfully.

Any ideas why the formatting doesn't 'stick' on these documents? What about
adding a field switch to the INCLUDETEXT field, like *Charformat or something?

"macropod" wrote:

Hi JAnderson,

I think you'll get the results you're after if you make the first character of each of the 'animal' documents a continuous
Section
break and if you insert a continuous Section break in your mailmerge document after the mergefields also. Alternatively, if you
want
each of the 'animal' documents to start on a new page, and the mailmerge document to resume on a new page after that, make the
section breaks 'next page'.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,







  #10  
Old July 19th, 2008, 09:48 AM posted to microsoft.public.word.mailmerge.fields
macropod[_2_]
external usenet poster
 
Posts: 2,402
Default Mergefields, IF statements and section breaks

Hi JAnderson,

The symptoms you're describing suggest the source document has a different paper size than the target document.

As for indents & tabs, are you sure they're defined using the same defaults for both the source and target documents?

Do you think I should try a section break at the beginning AND end of the source documents?

Wouldn't hurt, especially if that Section break reverts the page layout settings to those used in the target document.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
From what you're describing, what I'm doing should work perfectly, you're
right. The best way I can describe what is going on is that only the first
page of my final product seems to observe the formatting; all remaining pages
revert to the target document's default settings. Furthermore, the text from
the source document does not line up with the indent arrows - instead it
falls off to the left of the page. It's very unusual. The same thing
happens with the header and footer on all pages after the first page.

Do you think I should try a section break at the beginning AND end of the
source documents? I'm SO close, I feel like I'm just missing one step.

Thanks again for all of your help,


"macropod" wrote:

Hi JAnderson,

Provided your:
.. source document (ie the one referenced by the INCLUDETEXT field) starts off with a Section break; and
.. target document (ie your mailmerge main document) has a Section break after the mergefields,
I don't believe the Section breaks in the source document will have any effect on the target document outside of those Section
breaks.

As for the partial shifting, are you sure the source and target documents have the same page formats (eg A4)?

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ok, we're definitely getting closer - thank you! I did what you suggested by
placing a continuous section break at the beginning of my 'animal' documents,
and placed a section break after my INCLUDETEXT field.

Two problems:

1) Some of my 'animal' documents have multiple section breaks within the
document (separate footers, etc.). I'm not sure how this is affecting the
resulting document.

2) My resulting merged document only retains the correct formatting for the
first page, then reverts to the default formatting of the 'primary/host'
document. Furthermore, all text and headers/footers are shifted partially
off the visible area of the page (these are not unusual documents, just text
and some tables within the printable margins of a page).

I'm encouraged by the results so far; I really want to get to the point
where my INCLUDETEXT field can LITERALLY pull the entire document. All
mergefields within the INCLUDETEXT document are merging correctly, thankfully.

Any ideas why the formatting doesn't 'stick' on these documents? What about
adding a field switch to the INCLUDETEXT field, like *Charformat or something?

"macropod" wrote:

Hi JAnderson,

I think you'll get the results you're after if you make the first character of each of the 'animal' documents a continuous
Section
break and if you insert a continuous Section break in your mailmerge document after the mergefields also. Alternatively, if
you
want
each of the 'animal' documents to start on a new page, and the mailmerge document to resume on a new page after that, make the
section breaks 'next page'.

--
Cheers
macropod
[MVP - Microsoft Word]


"JAnderson" wrote in message ...
Ah, that makes sense, thank you. It looks like the last of my problems is
formatting.

Each of my documents has different page setup dimensions (margins,
header/footer, etc.), by they seem to take on that of the main "host"
document, rather than keeping their original formatting. I can't think of a
way around this, but everything else is looking pretty good.

Any ideas? Thanks as always,


"Graham Mayor" wrote:

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,








 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:14 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.