Reply
 
Thread Tools Display Modes
  #1   Report Post  
Dave
 
Posts: n/a
Default Conditionally display a paragraph using a MailMerge field?

Hello,
I'm developing a word document for use with merge data, and one of the
requirements of the document is to conditionally display a paragraph based on
the value of a MergeField. I've considered using a sequence of {IF ... }
fields, but that is neither elegant nor does it maintain proper paragraph
spacing between the paragraph above and below. Any ideas?
Thanks,
Dave
  #2   Report Post  
Mark V
 
Posts: n/a
Default

Dave,

Just went through this exercise. I've been able to get the spacing to work
out using a series of {IF} statements. You have at least three options that
you can try:

1. Create and format the paragraph or paragraphs that you want to use.
Insert an {IF} statement where you would like these paragraphs to appear
(using Control+F9 and typing in the conditional statement between the
brackets). Be sure to use Control+F9 to insert any other fields that you
want to include in the statement (you can't just type in the brackets). For
the THEN and ELSE text in the {IF} statement just put pairs of quotes ("") as
placeholders. Your {IF} statment will essentially be {IF condition "" ""}.
Leaving the {IF} statement visible (don't Toggle Field Codes or Update Field
yet), cut and paste the paragraph or paragraphs created above between the
placeholder quotes. Your {IF} statement will now look something like {IF
condition "paragraph1 text" "paragraph2 text"}. Keep in mind that the
statement won't appear all on one line but will instead look a bit messy and
span multiple. Once you've finished pasting in the desired paragraphs, hit
F9 to update the field (or right click and select Update Field) and you
should see the results. Test the conditional statement and formatting with a
data source to be sure that it looks the way you want. If not, you'll have
to toggle field codes again to mess around with it.

2. Create a document or documents with the paragraph or paragraphs that you
want to use formatted as you'd like them to appear. Save each document and
remember the path and file name. Insert your {IF} statement as outlined
above but instead of cutting and pasting in paragraphs between the quotes,
use the {INCLUDETEXT} field to insert the paragraphs from the documents.
Your {IF} statment will look something like {IF condition "{INCLUDETEXT
"paragraph1.doc"}" "{INCLUDETEXT "paragraph2.doc"}"}. Check Word help for
more info on {INCLUDETEXT} syntax and options, especially how to correctly
specify the path. Note: You can also create multiple paragraphs in a single
Word doc, create bookmarks for them and refer to the specific paragraphs by
using the bookmarks within the {INCLUDETEXT} field.

3. Create and format the paragraph or paragraphs that you want to use.
Highlight them and create AutoText entries by selecting Insert, AutoText from
the main menu and using an easy-to-remember name for each (don't include any
spaces in the AutoText name since the {AUTOTEXT} field that you will use
below doesn't like spaces). Insert your {IF} statement as outlined above but
put an {AUTOTEXT} field between the quotes instead. Your {IF} statement will
look something like {IF condition "{AUTOTEXT paragraph1autotext} "{AUTOTEXT
paragraph2autotext"}}. Check Word help for more info on {AUTOTEXT} syntax
and options.

Hope this helps.

Regards,

Mark V

"Dave" wrote:

Hello,
I'm developing a word document for use with merge data, and one of the
requirements of the document is to conditionally display a paragraph based on
the value of a MergeField. I've considered using a sequence of {IF ... }
fields, but that is neither elegant nor does it maintain proper paragraph
spacing between the paragraph above and below. Any ideas?
Thanks,
Dave

  #3   Report Post  
Dave
 
Posts: n/a
Default


Thanks Mark! The "IF" approach in #1 worked well! It took a little work to
get formatting and other embedded fields to work, but the trick, as you
mentioned, is to use Ctrl+F9 for any embedded fields. Now in the merged
document, I get an extra page break between records...but that's a different
problem...

Thanks again,
Dave


"Mark V" wrote:

Dave,

Just went through this exercise. I've been able to get the spacing to work
out using a series of {IF} statements. You have at least three options that
you can try:

1. Create and format the paragraph or paragraphs that you want to use.
Insert an {IF} statement where you would like these paragraphs to appear
(using Control+F9 and typing in the conditional statement between the
brackets). Be sure to use Control+F9 to insert any other fields that you
want to include in the statement (you can't just type in the brackets). For
the THEN and ELSE text in the {IF} statement just put pairs of quotes ("") as
placeholders. Your {IF} statment will essentially be {IF condition "" ""}.
Leaving the {IF} statement visible (don't Toggle Field Codes or Update Field
yet), cut and paste the paragraph or paragraphs created above between the
placeholder quotes. Your {IF} statement will now look something like {IF
condition "paragraph1 text" "paragraph2 text"}. Keep in mind that the
statement won't appear all on one line but will instead look a bit messy and
span multiple. Once you've finished pasting in the desired paragraphs, hit
F9 to update the field (or right click and select Update Field) and you
should see the results. Test the conditional statement and formatting with a
data source to be sure that it looks the way you want. If not, you'll have
to toggle field codes again to mess around with it.

2. Create a document or documents with the paragraph or paragraphs that you
want to use formatted as you'd like them to appear. Save each document and
remember the path and file name. Insert your {IF} statement as outlined
above but instead of cutting and pasting in paragraphs between the quotes,
use the {INCLUDETEXT} field to insert the paragraphs from the documents.
Your {IF} statment will look something like {IF condition "{INCLUDETEXT
"paragraph1.doc"}" "{INCLUDETEXT "paragraph2.doc"}"}. Check Word help for
more info on {INCLUDETEXT} syntax and options, especially how to correctly
specify the path. Note: You can also create multiple paragraphs in a single
Word doc, create bookmarks for them and refer to the specific paragraphs by
using the bookmarks within the {INCLUDETEXT} field.

3. Create and format the paragraph or paragraphs that you want to use.
Highlight them and create AutoText entries by selecting Insert, AutoText from
the main menu and using an easy-to-remember name for each (don't include any
spaces in the AutoText name since the {AUTOTEXT} field that you will use
below doesn't like spaces). Insert your {IF} statement as outlined above but
put an {AUTOTEXT} field between the quotes instead. Your {IF} statement will
look something like {IF condition "{AUTOTEXT paragraph1autotext} "{AUTOTEXT
paragraph2autotext"}}. Check Word help for more info on {AUTOTEXT} syntax
and options.

Hope this helps.

Regards,

Mark V

"Dave" wrote:

Hello,
I'm developing a word document for use with merge data, and one of the
requirements of the document is to conditionally display a paragraph based on
the value of a MergeField. I've considered using a sequence of {IF ... }
fields, but that is neither elegant nor does it maintain proper paragraph
spacing between the paragraph above and below. Any ideas?
Thanks,
Dave

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple styles in a single paragraph skibikegolf Microsoft Word Help 1 January 5th 05 09:57 AM
How do I use the PRINT field code to ... Dave Microsoft Word Help 3 December 13th 04 03:06 PM
Filename field - display problem with \p option IanB Page Layout 0 December 9th 04 03:35 PM
Text Form Field Ref in Footer Won't Update on Screen StarWine Microsoft Word Help 3 December 6th 04 06:17 PM
field calculation error, mailmerge, Cindy M -WordMVP- Mailmerge 0 November 30th 04 05:25 PM


All times are GMT +1. The time now is 02:20 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"