Previous Document Next Document

Object Model Reference : Classes : T : Text : Methods : Text.Replace


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])

Description

Member of Text

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

Parameter
Description
OldText
Specifies the text to be replaced
NewText
Specifies the text that replaces the text in the OldText parameter
CaseSensitive
Specifies whether to match the case of the text in the Text parameter
StartIndex
Specifies the first text object in the 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
Specifies 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
Specifies 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, through a value of cdrTextIndexingType, the type of text to find. The indexing type can be character, word, or paragraph. This parameter is optional, and its default value is cdrCharacterIndexing (0).

VBA example

The following VBA 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 2013 Corel Corporation. All rights reserved.