Text Property Example

This example displays the text in the selection. If nothing is selected, the character following the insertion point is displayed.

MsgBox Selection.Text

This example replaces the first word in the active document with "Dear."

Set myRange = ActiveDocument.Words(1)
myRange.Text = "Dear "

This example inserts 10 lines of text into a new document.

Documents.Add
For i = 1 To 10
    Selection.Text = "Line" & Str(i) & Chr(13)
    Selection.MoveDown Unit:=wdParagraph, Count:=1
Next i

This example replaces "Hello" with "Goodbye" in the active document.

Set myRange = ActiveDocument.Content
With myRange.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Text = "Hello"
    .Replacement.Text = "Goodbye"
    .Execute Replace:=wdReplaceAll
End With