ContentControlListEntries.Add Method

Word Developer Reference

Adds a new list item to a drop-down list or combo box content control and returns a ContentControlListEntry object.

Syntax

expression.Add(Text, Value, Index)

expression   An expression that returns a ContentControlListEntries object.

Parameters

Name Required/Optional Data Type Description
Text Required String Specifies the display text for the list item. Corresponds to the Text property for a ContentControlListEntry object.
Value Optional 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 Optional 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.

Return Value
ContentControlListEntry

Remarks

List entries must have unique display names. Attempting to add a list item that already exists raises a run-time error.

Example

The following example creates a new drop-down list content control and then adds several items to it.

Visual Basic for Applications
  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"

See Also