TextRetrievalMode.IncludeFieldCodes property (Word)

True if the text retrieved from the specified range includes field codes. Read/write Boolean.

Syntax

expression. IncludeFieldCodes

expression An expression that returns a 'TextRetrievalMode' object.

Remarks

The default value is the same as the setting of the Field codes option on the View tab in the Options dialog box (Tools menu) until this property has been set.

Use the Text property with a Range object to retrieve text from the specified range.

Example

This example displays the text of the first paragraph in the active document in a message box. The example uses the IncludeFieldCodes property to exclude field codes.

Dim rngTemp As Range 
 
Set rngTemp = ActiveDocument.Paragraphs(1).Range 
 
rngTemp.TextRetrievalMode.IncludeFieldCodes = False 
MsgBox rngTemp.Text

This example excludes field codes and hidden text from the range that refers to the selected text, and then it displays the text in a message box.

Dim rngTemp As Range 
 
If Selection.Type = wdSelectionNormal Then 
 Set rngTemp = Selection.Range 
 With rngTemp.TextRetrievalMode 
 .IncludeHiddenText = False 
 .IncludeFieldCodes = False 
 End With 
 MsgBox rngTemp.Text 
End If

See also

TextRetrievalMode Object

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.