<< Click to Display Table of Contents >> ListEntries (collection) |
Access paths:
▪Application à Documents à Item à FormFields à Item à DropDown à ListEntries
▪Application à ActiveDocument à FormFields à Item à DropDown à ListEntries
1 Description
ListEntries is a collection of all list entries of a DropDown object. This allows you to view and edit the individual entries in a selection list.
The individual elements of this collection are of the type ListEntry.
2 Access to the collection
Each DropDown form object has exactly one instance of the ListEntries collection. It is accessed through DropDown.ListEntries:
' Show the number of list entries in the first form element
' (if it is really a drop-down list)
If tm.ActiveDocument.FormFields(1).DropDown.Valid Then
MsgBox tm.ActiveDocument.FormFields(1).DropDown.ListEntries.Count
End If
3 Properties, objects, collections and methods
Properties:
▪Count R/O
Objects:
▪Item → ListEntry (default object)
▪Application → Application
▪Parent → DropDown
Methods:
▪Add
▪Clear
Count (property, R/O)
Data type: Long
Returns the number of ListEntry objects in the collection – in other words: the number of entries in the drop-down list.
Item (pointer to object)
Data type: Object
Returns an individual ListEntry object, i.e. an individual list entry in the drop-down list.
Which ListEntry object you get depends on the parameter that you pass to Item. You can specify either the numeric index or the name of the desired list entry. Examples:
' Show the first list entry
MsgBox tm.FormFields(1).DropDown.ListEntries.Item(1).Name
' Show the list entry with the text "Test"
MsgBox tm.FormFields(1).DropDown.ListEntries.Item("Test").Name
Application (pointer to object)
Data type: Object
Returns the Application object.
Parent (pointer to object)
Data type: Object
Returns the parent object, i.e. an object of the type DropDown.
Add (method)
Adds a new entry to the drop-down list.
Syntax:
Add Name
Parameters:
Name (type: String) specifies the string to be added. |
Return type:
Object (a ListEntry object that represents the new entry) |
Example:
' Add an entry to the first form field in the document (a drop-down list)
tm.ActiveDocument.FormFields(1).DropDown.ListEntries.Add "Green"
' The same, but using the return value (mind the parentheses!)
Dim entry as Object
Set entry = tm.ActiveDocument.FormFields(1).DropDown.ListEntries.Add("Green")
Clear (method)
Deletes all entries from the drop-down list.
Syntax:
Clear
Parameters:
none |
Return type:
none |
Example:
' Delete all entries from the first form field in the document
tm.ActiveDocument.FormFields(1).DropDown.ListEntries.Clear