TextRange Object
PowerPoint Developer Reference |
Contains the text that's attached to a shape, and properties and methods for manipulating the text.
Remarks
The following examples describe how to:
- Return the text range in any shape you specify.
- Return a text range from the selection.
- Return particular characters, words, lines, sentences, or paragraphs from a text range.
- Find and replace text in a text range.
- Insert text, the date and time, or the slide number into a text range.
- Position the cursor wherever you want in a text range.
Example
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.
Visual Basic for Applications |
---|
|
Because the Text property is the default property of the TextRange object, the following two statements are equivalent.
Visual Basic for Applications |
---|
|
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.
Use the TextRange property of the Selection object to return the currently selected text. The following example copies the selection to the Clipboard.
Visual Basic for Applications |
---|
|
Use one of the following methods to return a portion of the text of a TextRange object: Characters , Lines , Paragraphs , Runs , Sentences , or Words .
Use the Find and Replace methods to find and replace text in a text range.
Use one of the following methods to insert characters into a TextRange object: InsertAfter , InsertBefore , InsertDateTime , InsertSlideNumber , or InsertSymbol .
See Also