Range Property

Microsoft Word Visual Basic

object that represents the portion of a document that's contained in the specified object.

expression.Range

expression    Required. An expression that returns one of the objects in the Applies To list.

Remarks

For information about returning a range from a document or returning a shape range from a collection of shapes, see the Range method.

Example

This example applies the Heading 1 style to the first paragraph in the active document.

ActiveDocument.Paragraphs(1).Range.Style = wdStyleHeading1
		

This example copies the first row in table one.

If ActiveDocument.Tables.Count >= 1 Then _
    ActiveDocument.Tables(1).Rows(1).Range.Copy
		

This example changes the text of the first comment in the document.

With ActiveDocument.Comments(1).Range
    .Delete
    .InsertBefore "new comment text"
End With
		

This example inserts text at the end of section one.

Set myRange = ActiveDocument.Sections(1).Range
With myRange
    .MoveEnd Unit:=wdCharacter, Count:=-1
    .Collapse Direction:=wdCollapseEnd
    .InsertParagraphAfter
    .InsertAfter "End of section"
End With