Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2002 Template

Status
Not open for further replies.

SoccerRocks

Technical User
Oct 6, 2005
3
US
I have accepted the task of coordinating all Referee classes in my area. I have created a Word Template on which the user provides information that I need before I can set up the class. There are 5 different types of classes available. I have 10 pieces of information that I need. 8 of those pieces of information are static, I need them for every class type. 2 of these pieces of information vary based on which type of class is being requested.

I want to provide one drop box at the top of the form that contains the five types of classes and then I want the two pieces of information that vary to adjust according to what is in that first drop down box.

One of those "Variable" pieces needs to show for 3 of the class types, but can be hidden for the other two as it is irrelevant.

Can anyone help me?
 
I have created a Word Template"

So what do you have, exactly, so far?

This is not difficult. Make your five types items in a dropdown formfield. Write a OnExit macro for it.

The OnExit macro tests the value selected in the five item formfield, and using logic, loads up the items in the second dropdown.

My FAQ on formfields here has some examples of this. But to start you off.

The "FiveItem" formfield has the five items.
The "TwoItem" formfield has the variable two items.
The procedure is executed as the OnExit macro for the FiveItem formfield.
Code:
Sub FiveItemsExit()
Dim DocFF As Formfields
Dim oFF As Formfield
' set formfield objects

Set DocFF = ActiveDocument.Formfields
Set TwoItem = DocFF("TwoItem")

' test FiveItem formfield value
Select Case DocFF("FiveItems").Result
   Case  "Yogi Bear"
        TwoItem.DropDown.ListEntries.Clear
        TwoItem.DropDown.ListEntries.Add "Item 1"
        TwoItem.DropDown.ListEntries.Add "Item 2"
   Case  "Whatever"
        TwoItem.DropDown.ListEntries.Clear
        TwoItem.DropDown.ListEntries.Add "ItemOther 1"
        TwoItem.DropDown.ListEntries.Add "ItemOther 2"
   Case  "YaddaYadda"
        ' stuff not needed in TwoItem, so clear
        TwoItem.DropDown.ListEntries.Clear
        ' and don't Add anything
   Case   ....etc
End Select
End Sub
If you are putting variable values into a dropdown, always make sure you explicitly clear it first. Otherwise items are....added, and added, and added

This is VBA solution. Further questions regarding this should be posted to the VBA forum.

faq219-2884

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top