Word) (ContentControlListEntry.Text 屬性

會傳回或設定代表清單項目下拉式清單或下拉式方塊內容控制項的顯示文字的 String 。 讀取/寫入。

語法

運算式文本

表達 會傳回 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

另請參閱

ContentControlListEntry 物件

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應