Class ContentControlListEntries (Word VBA)
The ContentControlListEntries collection contains ContentControlListEntry objects that represent the items in a drop-down list or combo box content control. To use a ContentControlListEntries class variable it first needs to be instantiated, for example
Dim ccls as ContentControlListEntries
Set ccls = ActiveDocument.Range.ContentControls(1).DropdownListEntries
Add
Adds a new list item to a drop-down list or combo box content control and returns a ContentControlListEntry object.
List entries must have unique display names. Attempting to add a list item that already exists raises a run-time error.
Dim objCC As ContentControl
Dim objLE As ContentControlListEntry
Dim objMap As XMLMapping
Set objCC = ActiveDocument.ContentControls.Add(wdContentControlDropdownList)
'List items
objCC.DropdownListEntries.Add "Cat"
objCC.DropdownListEntries.Add "Dog"
objCC.DropdownListEntries.Add "Equine"
objCC.DropdownListEntries.Add "Monkey"
objCC.DropdownListEntries.Add "Snake"
objCC.DropdownListEntries.Add "Other"
Arguments
The following argument is required
Text (String) - Specifies the display text for the list item. Corresponds to the Text property for a ContentControlListEntry object.
Optional arguments
The following arguments are optional
Value (String) - Specifies the value of the list item. Corresponds to the Value property for a ContentControlListEntry object. If omitted, the Value property is equal to the Text property.
Index (Long) - Specifies the ordinal position of the new item in the list. If an item exists at the position specified, the existing item is pushed down in the list. If omitted, the new item is added to the end of the list.
Clear
Clears all items from a drop-down list or combo box content control.
Dim objCC As ContentControl
Set objCC = ActiveDocument.ContentControls(1)
objCC.DropdownListEntries.Clear
Count
Returns the number of items in the ContentControlListEntries collection.
Dim lngCount As Long
lngCount = ActiveDocument.Range.ContentControls(1).DropdownListEntries.Count
Item
Returns a ContentControlListEntry object that represents the specified item in the collection.
Item (Index)
Index: Specifies the ordinal position of the object within the collection.
Dim ccl As ContentControlListEntry
Set ccl = ActiveDocument.Range.ContentControls(1).DropdownListEntries(Index:=1)