Reading and Changing Range Text

The Range object has a Text property that returns the text in the specified range. You can also use the Text property to set the text within the specified range. For example, the following code fragment checks the text in a document called letter.docx to see whether the first four characters equal the string "Dear"; if so, the text is replaced with "Greetings":

With Documents("letter.docx").Range.(0,4) If .Text = "Dear" Then .Text = "Greetings" End If End With

0 0

Post a comment