Previous Document Next Document
Text.Replace

Sub Replace(OldText As String, NewText As String, CaseSensitive As Boolean, [StartIndex As Long = 1], [ReplaceAll As Boolean = False], [WrapAround As Boolean = False], [IndexingType As cdrTextIndexingType = cdrCharacterIndexing])

Member of Text

The Replace method replaces one text string with another in a text stream.

Parameters
Description
OldText
Specifies the text to be replaced. The string must be contained within quotation marks.
NewText
Specifies the text that replaces the text in the OldText parameter. The string must be contained within quotation marks.
CaseSensitive
Determines whether to match the case of the text in the Text parameter
StartIndex
Specifies the first text object in a text range. If the index type is set to word, and the start index is 3, the StartIndex parameter begins the range at the third word in the selected text frame.
This parameter is optional, and its default value is 1.
ReplaceAll
Determines whether all instances of old text found in the text range are replaced with new text
This parameter is optional, and its default value is False.
WrapAround
Determines whether the text follows the path of an object’s shape or bounding box
This parameter is optional, and its default value is False.
IndexingType
Specifies the type of text to find. The indexing type can be character, word, or paragraph. The IndexingType parameter has a value of cdrTextIndexingType.
This parameter is optional, and its default value is cdrCharacterIndexing (0).

The following code example replaces all occurrences of # on the page with the current date:

Sub Test() 
 Dim s As Shape 
 For Each s In ActivePage.FindShapes(, cdrTextShape) 
  s.Text.Replace "#", CStr(Date), False, ReplaceAll:=True 
 Next s 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.