On Sun, 15 Nov 2009 08:51:01 -0800, Petra van Vuurem <Petra van
How do I use the same drop down fields in multiple forms without recreating
the values with each form?
The only way to do that is to prepare a macro that populates the list.
Here's some sample code (see
http://www.gmayor.com/installing_macro.htm if needed):
Sub PopulateCityDropdown()
Dim FieldName As String
Dim WasProtected As Boolean
WasProtected = False
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect
WasProtected = True
End If
If Selection.FormFields.Count > 0 Then
FieldName = Selection.FormFields(1).Name
Else
FieldName = InputBox("Enter name of dropdown to fill:")
Do While Not ActiveDocument.Bookmarks.Exists(FieldName)
If StrPtr(FieldName) = 0 Then Exit Sub ' canceled
FieldName = InputBox("Enter name of dropdown to fill:")
Loop
End If
With ActiveDocument.FormFields(FieldName)
If .Type = wdFieldFormDropDown Then
.DropDown.ListEntries.Clear
.DropDown.ListEntries.Add "Akron"
.DropDown.ListEntries.Add "Boston"
.DropDown.ListEntries.Add "Chattanooga"
.DropDown.ListEntries.Add "Denver"
Else
MsgBox FieldName & " is not a dropdown."
Exit Sub
End If
End With
If WasProtected Then
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True
End If
End Sub
You'd need a different macro for each list, or else this macro would
have to be modified to recognize which list goes with which field
name.
The macro can be assigned to a shortcut key and/or a toolbar button.