Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
SetRange Method
Collapse the table of content
Expand the table of content

Range.SetRange Method (Word)

Sets the starting and ending character positions for an existing range.

expression .SetRange(Start, End)

expression Required. A variable that represents a Range object.

Parameters

Name

Required/Optional

Data Type

Description

Start

Required

Long

The starting character position of the range.

End

Required

Long

The ending character position of the range.

Character position values start at the beginning of the story, with the first value being 0 (zero). All characters are counted, including nonprinting characters. Hidden characters are counted even if they're not displayed.

The SetRange method redefines the starting and ending positions of an existing Range object. This method differs from the Range method, which is used to create a range, given a starting and ending position.

This example uses SetRange to redefine myRange to refer to the first three paragraphs in the active document.

Set myRange = ActiveDocument.Paragraphs(1).Range 
myRange.SetRange Start:=myRange.Start, _ 
 End:=ActiveDocument.Paragraphs(3).Range.End

This example uses SetRange to redefine myRange to refer to the area starting at the beginning of the document and ending at the end of the current selection.

Set myRange = ActiveDocument.Range(Start:=0, End:=0) 
myRange.InsertAfter "Hello " 
myRange.SetRange Start:=myRange.Start, End:=Selection.End

Concepts

Other resources

Show:
© 2015 Microsoft