次の方法で共有


ContentControlListEntry.Text プロパティ (Word)

返すまたは、ドロップダウン リスト ボックスまたはコンボ ボックス コンテンツ コントロールのリスト項目の表示テキストを表す 文字列 を設定します。 値の取得と設定が可能です。

構文

テキスト

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 のサポートおよびフィードバックを参照してください。