TextRange Object

         Properties         Methods

Multiple objects
TextRange object
ActionSettings collection (ActionSetting object)
Font object
ParagraphFormat object
TextRange object

Contains the text that's attached to a shape, as well as properties and methods for manipulating the text.

Using the TextRange Object

This section describes how to:

Returning a Text Range from Any Shape You Specify

Use the TextRange property of the TextFrame object to return a TextRange object for any shape you specify. Use the Text property to return the string of text in the TextRange object. The following example adds a rectangle to myDocument and sets the text it contains.

Set myDocument = ActivePresentation.Slides(1)
myDocument.Shapes.AddShape(msoShapeRectangle, 0, 0, 250, 140) _
    .TextFrame.TextRange.Text = "Here is some test text"

Because the Text property is the default property of the TextRange object, the following two statements are equivalent.

ActivePresentation.Slides(1).Shapes(1).TextFrame _
    .TextRange.Text = "Here is some test text"
ActivePresentation.Slides(1).Shapes(1).TextFrame _
    .TextRange = "Here is some test text"

Use the HasTextFrame property to determine whether a shape has a text frame, and use the HasText property to determine whether the text frame contains text.

Returning a Text Range from the Selection

Use the TextRange property of the Selection object to return the currently selected text. The following example copies the selection to the Clipboard.

ActiveWindow.Selection.TextRange.Copy

Returning Particular Characters, Words, Lines, Sentences, or Paragraphs from a Text Range

Use one of the following methods to return a portion of the text of a TextRange object: Characters, Lines, Paragraphs, Runs, Sentences, or Words.

Finding and Replacing Text in a Text Range

Use the Find and Replace methods to find and replace text in a text range.

Inserting Text, the Date and Time, or the Slide Number into a Text Range

Use one of the following methods to insert characters into a TextRange object: InsertAfter, InsertBefore, InsertDateTime, InsertSlideNumber, or InsertSymbol.