Range Method Example

This example applies bold formatting to the first 10 characters in the active document.

ActiveDocument.Range(Start:=0, End:=10).Bold = True

This example creates a range that starts at the beginning of the active document and ends at the end of the selection.

Set myRange = ActiveDocument.Range(Start:=0, End:=Selection.End)

This example creates sets the variable myRange to paragraphs three through six in the active document, and then it right aligns the paragraphs in the range.

Set aDoc = ActiveDocument
If aDoc.Paragraphs.Count >= 6 Then
    Set myRange = aDoc.Range(aDoc.Paragraphs(3).Range.Start, _
        aDoc.Paragraphs(6).Range.End)
    myRange.Paragraphs.Alignment = wdAlignParagraphRight
End If

This example sets the fill foreground color to purple for the first shape in the active document.

ActiveDocument.Shapes.Range(1).Fill _
    .ForeColor.RGB = RGB(255, 0, 255)

This example applies a shadow to the shape named "myshape" in the active document.

ActiveDocument.Shapes.Range("myshape").Shadow.Type = msoShadow6

This example selects shapes one and three in the active document.

ActiveDocument.Shapes.Range(Array(1, 3)).Select