共用方式為


TextRetrievalMode.IncludeFieldCodes Property

Word Developer Reference

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.

Visual Basic for Applications
  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.

Visual Basic for Applications
  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