IncludeFieldCodes Property

Microsoft Word Visual Basic

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

expression.IncludeFieldCodes

expression    Required. An expression that returns a TextRetrievalMode object.

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