Class ListEntries (Word VBA)

A collection of ListEntry objects that represent all the items in a drop-down form field. To use a ListEntries class variable it first needs to be instantiated, for example


Dim les as ListEntries
Set les = ActiveDocument.FormFields(1).DropDown.ListEntries

For Each

Here is an example of processing the ListEntries items in a collection.


Dim ley As ListEntry
For Each ley In ActiveDocument.FormFields(1).DropDown.ListEntries
	
Next ley

Add

Returns a ListEntry object that represents an item added to a drop-down form field.

Add (Name, Index)


Set myField = ActiveDocument.FormFields.Add(Range:= _ 
 Selection.Range, Type:= wdFieldFormDropDown) 
With myField.DropDown.ListEntries 
 .Add Name:="Red" 
 .Add Name:="Blue" 
 .Add Name:="Green" 
End With

Arguments

The following argument is required

Name (String) - The name of the drop-down form field item.

Optional arguments

The following argument is optional

Index (Long) - A number that represents the position of the item in the list.

Clear

Removes all items from a drop-down form field.


Documents("Sales.doc").FormFields("Colors") _ 
 .DropDown.ListEntries.Clear

Count

Returns a Long that represents the number of list entries in the collection.


Dim lngCount As Long
lngCount = ActiveDocument.FormFields(1).DropDown.ListEntries.Count

Item

Returns an individual ListEntry object in a collection.

Item (Index)

Index: The individual object to be returned. Can be a Long indicating the ordinal position or a String representing the name of the individual object.


Sub ListEntryItem() 
 Dim d As DropDown 
 Set d = ActiveDocument.FormFields.Add _ 
 (Range:=Selection.Range, _ 
 Type:=wdFieldFormDropDown).DropDown 
 With d.ListEntries 
 .Add Name:="Black" 
 .Add Name:="Green" 
 End With 
 MsgBox d.ListEntries.Item(1).Name 
End Sub