返回或设置一个 字符串 ,表示下拉列表或组合框内容控件列表项的显示文本。 读/写。
语法
表达式。文本
表达 返回 ContentControlListEntry 对象的表达式。
备注
列表中的项必须具有唯一的显示名称。 试图将 Text 属性更改为条目列表中已存在的字符串,将引发运行时错误。
示例
以下示例将每个列表项的显示文本中的第一个字符(如果是小写)变为大写。
Dim objCC As ContentControl 
Dim objLE As ContentControlListEntry 
Dim strFirst As String 
 
For Each objCC In ActiveDocument.ContentControls 
 If objCC.Type = wdContentControlComboBox Or objCC.Type = wdContentControlDropdownList Then 
 For Each objLE In objCC.DropdownListEntries 
 strFirst = Left(objLE.Text, 1) 
 
 If strFirst = LCase(strFirst) Then 
 objLE.Text = UCase(strFirst) & Right(objLe.Text, Len(objLe.Text) - 1) 
 End If 
 Next 
 End If 
Next
以下示例基于显示文本的内容来设置列表项的值。
Dim objCc As ContentControl 
Dim objLe As ContentControlListEntry 
Dim strText As String 
Dim strChar As String 
 
Set objCc = ActiveDocument.ContentControls(3) 
 
For Each objLE In objCC.DropdownListEntries 
 If objLE.Text <> "Other" Then 
 strText = objLE.Text 
 objLE.Value = "My favorite animal is the " & strText & "." 
 End If 
Next
另请参阅
支持和反馈
有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。