Class DropDown (Word VBA)

The class DropDown represents a drop-down form field that contains a list of items in a form.

Set

To use a DropDown class variable it first needs to be instantiated, for example

Dim ddn as DropDown
Set ddn = ActiveDocument.FormFields(1).DropDown

DropDown class variables can be set using the FormField.DropDown procedure.

Default

Returns or sets a Long that represents the default drop-down item.

The first item in a drop-down form field is 1, the second item is 2, and so on.

Documents("Sales.doc").FormFields("Colors").DropDown _ 
 .Default = 2

ListEntries

Returns a ListEntries collection that represents all the items in a DropDown object.

For information about returning a single member of a collection, see Returning an object from a collection.

Set myField = ActiveDocument.FormFields("DropDown1").DropDown 
num = myField.Value 
myName = myField.ListEntries(num).Name

Parent

Returns an object that represents the parent object of the specified DropDown object.

Dim objParent As Object
Set objParent = ActiveDocument.FormFields(1).DropDown.Parent

Valid

True if the specified form field object is a valid drop down form field.

Use the Type property of the FormField object to determine the type of form field (wdFieldFormDropDown) before applying the DropDown property. This precaution ensures that the FormField object is of the expected type.

Dim booValid As Boolean
booValid = ActiveDocument.FormFields(1).DropDown.Valid

Value

Returns or sets the number of the selected item in a drop-down form field.

ActiveDocument.FormFields(1).DropDown.Value =