ContentControlListEntry 方法 (Word)ContentControlListEntry.Select method (Word)

选择下拉列表或组合框内容控件中的列表项, 并将内容控件的文本设置为该项的值。Selects the list entry in a drop-down list or combo box content control and sets the text of the content control to the value of the item.

语法Syntax

表达式选择expression.Select

_表达式_一个返回ContentControlListEntry对象的表达式。expression An expression that returns a ContentControlListEntry object.

示例Example

以下示例在活动文档中插入下拉列表内容控件,设置标题和占位符文本并在列表中添加几个项,然后选择输入的最后一项。The following example inserts a drop-down list content control into the active document, sets the title and placeholder text and adds several items to the list, and then selects the last item entered.

Dim objCC As ContentControl 
Dim objCE As ContentControlListEntry 
Dim objMap As XMLMapping 
 
Set objCC = ActiveDocument.ContentControls.Add(wdContentControlDropdownList) 
objCC.Title = "My Favorite Animal" 
If objCC.ShowingPlaceholderText Then _ 
 objCC.SetPlaceholderText , , "Select your favorite animal " 
 
'List entries 
objCC.DropdownListEntries.Add "Cat" 
objCC.DropdownListEntries.Add "Dog" 
objCC.DropdownListEntries.Add "Horse" 
objCC.DropdownListEntries.Add "Monkey" 
objCC.DropdownListEntries.Add "Snake" 
 
Set objCE = objCC.DropdownListEntries.Add("Other") 
objCE.Select

另请参阅See also

ContentControlListEntry 对象ContentControlListEntry Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.