使用 Text 属性可以返回 Range 或 Selection 对象中的文本。下列示例选定下一个格式设为“标题 1”样式的段落。然后通过 MsgBox 函数显示 Text 属性的内容。

Sub FindHeadingStyle()
    With Selection.Find
        .ClearFormatting
        .Style = wdStyleHeading1
        .Execute FindText:="", Format:=True, _
            Forward:=True, Wrap:=wdFindStop
        If .Found = True Then MsgBox Selection.Text
    End With
End Sub
下列指令返回并显示选定的文本。

Sub ShowSelection()
    Dim strText As String
    strText = Selection.Text
    MsgBox strText
End Sub
下列示例返回活动文档中的第一个单词。Words 集合中的每一项是代表一个单词的 Range 对象。

Sub ShowFirstWord()
    Dim strFirstWord As String
    strFirstWord = ActiveDocument.Words(1).Text
    MsgBox strFirstWord
End Sub
下列示例返回与活动文档中第一个书签相关联的文本。

Sub ShowFirstBookmark()
    Dim strBookmark As String
    If ActiveDocument.Bookmarks.Count > 0 Then
        strBookmark = ActiveDocument.Bookmarks(1).Range.Text
        MsgBox strBookmark
    End If
End Sub