Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
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
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mergefields, IF statements and section breaks
I have read this entire thread with interest because I am trying to do
something similar, though more simple. I have a document that uses a mail merge. I created the IF statement, with the INSERTTEXT field and a next page break. But it will not open the file. The file is buried pretty deep on a network server - but in the same folder as the original document. Both documents and folders leading to the documents have spaces in their filenames. I tried replacing the spaces with underscores - but no luck. This is my statement: {IF {MERGEFIELD course} = €śCourse D€ť "{INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"}" ""} I am using the letter drive, not the network drive name. Thanks Nik |
#8
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
Mergefields, IF statements and section breaks
If the filename has spaces then the spaces must remain in the field.
Forget the merge for a moment. Does {INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"} or {INCLUDETEXT "J:\\Dept\\staff\\2009\\letter Page 3.doc"} insert the document? If it does not, check the path and filename are correct. Once you have the insertion working, you can add the field to your merge document {IF {MERGEFIELD course} = "Course D" "{INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"}" ""} Note that in the above which I have pasted from your question, you have smart quotes around Course D. You need to change those for straight quotes thus {IF {MERGEFIELD course} = "Course D" "{INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"}" ""} Your next page break needs to go inside the quotes around the Includetext field "HERE{INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"}OR HERE" ""} You may also need to merge to a new document and update the fields in that new document in order to display the inserted document. -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Nicole Knapp wrote: I have read this entire thread with interest because I am trying to do something similar, though more simple. I have a document that uses a mail merge. I created the IF statement, with the INSERTTEXT field and a next page break. But it will not open the file. The file is buried pretty deep on a network server - but in the same folder as the original document. Both documents and folders leading to the documents have spaces in their filenames. I tried replacing the spaces with underscores - but no luck. This is my statement: {IF {MERGEFIELD course} = "Course D" "{INCLUDETEXT "J:\\Dept\\staff\\2009\\letter_Page_3.doc"}" ""} I am using the letter drive, not the network drive name. Thanks Nik |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Replace Section Breaks with Page Breaks Automatically? | Microsoft Word Help | |||
Continuous Section breaks, Next page section breaks, headers and f | Page Layout | |||
replace auto page breaks with section breaks | Page Layout | |||
Converting page breaks to section breaks automatically- 2007 | Page Layout | |||
Replace Section Breaks with Page Breaks Automatically? | Microsoft Word Help |