ListEntries
Represents a drop-down form field that contains a list of items in a form.
Using the DropDown Object
Use FormFields(index), where index is the index number or the bookmark name associated with the drop-down form field, to return a single FormField object. Use the DropDown property with the FormField object to return a DropDown object. The following example selects the first item in the drop-down form field named "DropDown" in the active document.
ActiveDocument.FormFields("DropDown1").DropDown.Value = 1
The index number represents the position of the form field in the FormFields collection. The following example checks the type of the first form field in the active document. If it's a drop-down form field, the second item is selected.
If ActiveDocument.FormFields(1).Type = wdFieldFormDropDown Then
ActiveDocument.FormFields(1).DropDown.Value = 2
End If
The following example determines whether form field represented by ffield
is a valid drop-down form field before adding an item to it.
Set ffield = ActiveDocument.FormFields(1).DropDown
If ffield.Valid = True Then
ffield.ListEntries.Add Name:="Hello"
Else
MsgBox "First field is not a drop down"
End If
Use the Add method with the FormFields collection to add a drop-down form field. The following example adds a drop-down form field at the beginning of the active document and then adds items to the form field.
Set ffield = ActiveDocument.FormFields.Add( _
Range:=ActiveDocument.Range(Start:=0, End:=0), _
Type:=wdFieldFormDropDown)
With ffield
.Name = "Colors"
With .DropDown.ListEntries
.Add Name:="Blue"
.Add Name:="Green"
.Add Name:="Red"
End With
End With