TextRange Object
Publisher Developer Reference |
Contains the text that is attached to a shape, in addition to properties and methods for manipulating the text. This topic describes 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.
- Insert text, the date and time, or the page number into 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 the active publication 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 , or Words . The following example formats the second word in the first shape on the first page of the active publication. For this example to work, the specified shape must contain text.
Visual Basic for Applications |
---|
|
Use one of the following methods to insert characters into a TextRange object: InsertAfter , InsertBefore , InsertDateTime , InsertPageNumber , or InsertSymbol . This example inserts a new line with text after any existing text in the first shape on the first page of the active publication.
Visual Basic for Applications |
---|
|
See Also