Collapse the table of content
Expand the table of content
Expand Minimize

Selecting Text in a Document

Office 2013 and later
GitHub-Mark-64px

Contribute to this content

Use GitHub to suggest and submit changes. See our guidelines for contributing to VBA documentation.

Use the Select method to select an item in a document. The Select method is available from several objects, such as Bookmark, Field, Range, and Table. The following example selects the first table in the active document.

Sub SelectTable() 
 ActiveDocument.Tables(1).Select 
End Sub

The following example selects the first field in the active document.

Sub SelectField() 
 ActiveDocument.Fields(1).Select 
End Sub

The following example selects the first four paragraphs in the active document. The Range method is used to create a Range object that refers to the first four paragraphs. The Select method is then applied to the Range object.

Sub SelectRange() 
 Dim rngParagraphs As Range 
 Set rngParagraphs = ActiveDocument.Range( _ 
 Start:=ActiveDocument.Paragraphs(1).Range.Start, _ 
 End:=ActiveDocument.Paragraphs(4).Range.End) 
 rngParagraphs.Select 
End Sub

For more information, see Working with the Selection object.

Show:
© 2016 Microsoft