Automatic Conditional Text Creation - possible in word?

G

GavSmith

Hello,

I'm a sys admin with little 'advanced' word knowledge like
macro's/forms etc and was wondering whether this is possible.

I need to create a document with 4 different variations on one page
only (address of office's), the rest of the document will be exactly
the same.

Other that using Auto-Text that the user would do manually, can I
create a document with something like a drop down box, that would
automatically
populate say a table on the last page with the relevant address.

e.g Option 1 in drop down - Office 1 address on back page

Is this in any way feasible ?- I imagine it can be done with macro's
somehow, but would rather not go down that route if possible and stick
to standard
word features. However, if that's the only way, I'll obviously have to
use it.

Any advices/ideas/tips/weblinks much appreciated.

Cheers
Gav
 
J

Jay Freedman

GavSmith said:
Hello,

I'm a sys admin with little 'advanced' word knowledge like
macro's/forms etc and was wondering whether this is possible.

I need to create a document with 4 different variations on one page
only (address of office's), the rest of the document will be exactly
the same.

Other that using Auto-Text that the user would do manually, can I
create a document with something like a drop down box, that would
automatically
populate say a table on the last page with the relevant address.

e.g Option 1 in drop down - Office 1 address on back page

Is this in any way feasible ?- I imagine it can be done with macro's
somehow, but would rather not go down that route if possible and stick
to standard
word features. However, if that's the only way, I'll obviously have to
use it.

Any advices/ideas/tips/weblinks much appreciated.

Cheers
Gav

Yes, that kind of document can be created. There are quite a few steps, but
you need to do them only once (and remember how they were done so you can
modify the document when an address changes or a new office has to be
added).

These instructions are for Word 2003 and earlier. If you have Word 2007, the
Forms gadgets are on the Legacy Controls button of the Developer ribbon (and
to see that ribbon you have to check the option in the Word Options >
Popular dialog), but everything else is the same.

Here's where we're going. An IF field consists of four parts: the keyword
'IF', an expression (formula) that can be true or false, a piece of text
that will be the field result when the expression is true, and a piece of
text that will be the field result when the expression is false. In this
case, the true/false expression checks whether the value of the dropdown is
equal to one of the office names. That office's address is the "true"
result, while another IF field is the "false" result. This nesting continues
until each of the possible names has been compared to the dropdown's value.

1. From the Forms toolbar, insert a Dropdown form field on the first page.

2. Double-click the dropdown to open its Properties dialog.

3. Add the names of the four offices to the list. Change the value of the
Bookmarks box from Dropdown1 to Office (or to something else descriptive).
Check the boxes for "Dropdown enabled" and "Calculate on exit". For this
example I'm going to describe just two offices, Los Angeles and New York,
and point to how you continue the process to add more. You also must insert
at least one other form field, so it becomes possible to tab from one field
to another when the document is in use.

4. Create a nested IF field (that is, a field with other fields inside it)
in the table on the last page. To create nested fields you must use Ctrl+F9
to create the field markers -- you can't just type the braces, or they won't
work. The field is complicated, so let's build it one piece at a time...

a. Start by typing a double-quote, the street address, Enter, the
city/state/zip, and a closing double-quote for one office. Then press Enter
and repeat for each of the other offices. For the two offices it would look
something like this:

“1902 Rodeo Drive

Los Angeles, CA 90018”

“435 54th St.

New York, NY 10019”



b. At the beginning of each address, insert the word IF, the name of the
dropdown form field, an equal sign, and the name of the office in
double-quotes. The name must match exactly what you typed into the
dropdown's list, including capitalization and any punctuation. Now the
example looks like this:

IF Office = “Los Angeles” “1902 Rodeo Drive

Los Angeles, CA 90018”

IF Office = “New York” “435 54th St.

New York, NY 10019”



c. Select the name of the dropdown field in each occurrence, and press
Ctrl+F9 to add field markers around it (remember, you can't just type
braces!):

IF { Office } = “Los Angeles” “1902 Rodeo Drive

Los Angeles, CA 90018”

IF { Office } = “New York” “435 54th St.

New York, NY 10019”



d. After the last address, add a space and a pair of double-quotes with
nothing between them:

IF { Office } = “Los Angeles” “1902 Rodeo Drive

Los Angeles, CA 90018”

IF { Office } = “New York” “435 54th St.

New York, NY 10019” ""



e. Select from the beginning of the last IF to the end of the empty quotes,
and press Ctrl+F9:

IF { Office } = “Los Angeles” “1902 Rodeo Drive

Los Angeles, CA 90018”

{ IF { Office } = “New York” “435 54th St.

New York, NY 10019” "" }



f. Select from the beginning of the next-to-last IF to the end of the final
field marker, and press Ctrl+F9:

{ IF { Office } = “Los Angeles” “1902 Rodeo Drive

Los Angeles, CA 90018”

{ IF { Office } = “New York” “435 54th St.

New York, NY 10019” "" } }

When you have more addresses, repeat this, selecting everything from the IF
before the one most recently enclosed all the way to the end and then
pressing Ctrl+F9. At the very end you should have as many closing braces as
you have addresses.



g. With the cursor somewhere in the big field, press F9 to update it. It
should now show one of the addresses, corresponding to the the office name
in the dropdown.



5. Protect the document for forms. In Word 2003 and earlier, click the lock
icon on the Forms toolbar. In Word 2007, click the Protect Document button
on the Developer ribbon; in the task pane that opens, check the box for
"Allow only this type of editing", select "Filling in forms" in the
dropdown, and click the Start Enforcing Portection button.



6. Save the document.



When you choose an office name in the dropdown and then tab to another form
field, the field at the end of the document will change to show the matching
address.


--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
D

DeanH

Hi Jay.
Many thanks for these instructions they came at exactly the right time and I
have now created such a auto-text-change.
One question though, once the section has been protected and the "Office"
dropdown is changed should the "Addresses" change automatically or, as in my
case, I get the Update Table of Contents dialog?
The dialog appears if I Tab off the dropdown, press ok and the "Addresses"
change as per requirements, but if I mouse click into the document elsewhere,
the changes do not occur.
I was hoping that the changes would happen regardless of how the user moves
around the document.
2003 on XP
Many thanks
DeanH
 
J

Jay Freedman

You shouldn't see the Update TOC dialog unless something is forcing an
update of all the fields in the document.

Now, what I'm seeing in a very simple document is that simply having a TOC
in the document prevents the "Calculate on exit" from updating the address
field, regardless of whether I tab or click out of the dropdown. Removing
the TOC makes it work again. I don't recall seeing this behavior before.
 
D

DeanH

Ah, well at least it is not something I did wrong! ;-)
Maybe when this was being developed, they thought that this would only be
used in Form type documents, which tend not to have TOCs.
The paticular document I am using this function within does have a TOC,
which I am disinclined to delete/convert.
At least I do have working Auto Conditional Text function, I shall just have
to train the users in this particular foible.
If you do happen acropss a solution, please pass on (as if you wouldn't) ;-)
Many thanks again.
DeanH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top