Namzaj said:
Hi,
I have a 40-page document that I'm trying to distribute to 2 groups.
About 60% of the doc is shared, but then there're pieces that are
only applicable to 1 group and not another. I'm looking for a
reasonably simple way to conditionally show Paragraphs based on a
button, a link, anything...
I'd like to maintain a single .doc file and just distribute a macro
to do this. I've searched Google for a while and haven't come up
with anything.
Hi Namzaj,
Here's one way to set this up...
Save the complete document as a template (.dot file). In File > Properties >
Custom, make a new custom property named Audience. Give it a value that
identifies one of the two groups, for example Instructor and Student.
Go to one of the pieces that should be conditional. Let's say it's a couple
of paragraphs that should appear for an instructor but not for a student.
Select the piece, including the paragraph mark at the end. Go to Tools >
AutoText > AutoText, set the Look In box to the name of the template (not
"All available templates"), give it a name for the entry (for this example,
call it piece1), and click Add and then OK.
Back in the document, delete the piece. In its place, insert an IF field
that looks like this (each of the inner fields must be inserted by pressing
Ctrl+F9):
{IF {DocProperty Audience} = "Instructor" {AutoText piece1}}
The value in quotes must match one of the values you're going to use for the
Audience custom property (it is case-sensitive), and the value following the
word AutoText must be the name of the entry you just created. Press F9 to
update the field.
If the value of the custom property matches the value in quotes in the IF
field, then the named AutoText entry will be inserted and should look just
like the original document. If they don't match, nothing will appear there.
Repeat this for all the other conditional pieces. Each AutoText entry must
have a distinct name (you can use descriptive names instead of piece1,
piece2, etc.). You can have an IF field that says IF {DocProperty Audience}
= "Instructor" and another that says IF {DocProperty Audience} = "Student"
adjacent to each other to have alternate displays, or you can combine them
into one field:
{IF {DocProperty Audience} = "Instructor" {AutoText piece1a} {AutoText
piece1b}}
will display piece1a for an Instructor or piece1b for a Student
(technically, for any value that is not "Instructor").
Finally, write a macro named AutoNew (see
http://www.gmayor.com/installing_macro.htm) that asks whether the current
document (created from the template by using File > New) will be an
Instructor document or a Student document. The macro uses the answer to set
the value of the Audience custom property, updates all fields in the
document, unlinks the fields, and opens the Save As dialog (or the Print
dialog, if you prefer). The unlinking will make the current appearance
permanent for that document. Post back if you need help with this macro.
If you need to make changes in the text, make them in the template and then
recreate new documents from the template. Unfortunately, you can't directly
edit an AutoText entry; you have to insert it temporarily somewhere in the
template -- say, at the end -- make the changes, and then select the whole
piece and add it as an AutoText entry with the same name as before. You'll
be prompted to make sure you want to replace the existing entry. Delete the
piece and save the template.