API Documentation > CorelDRAW > 2025-v26 > TextRange > IVGTextRange
TextRange.Replace method
Replaces the range with the text string and returns the new range
Syntax:
Function Replace(ByVal Text As String, Optional ByVal LanguageID As cdrTextLanguage = cdrLanguageNone, Optional ByVal CharSet As cdrTextCharSet = cdrCharSetMixed, Optional ByVal Font As String) As TextRange
Parameters:
Name Type Description
Text
String
LanguageID
Specifies the language code.
CharSet
Specifies the character set.
Font
String
Remarks:
The Replace method replaces a text range with a text string and returns the new range.
Examples:
The following VBA example replaces the first word with new text.
Sub Test()
Dim d As Document
Dim s As Shape
Dim t As Text
Set d = CreateDocument
Set s = d.ActiveLayer.CreateParagraphText(3, 3, 5, 5, _
  "This is an example.")
Set t = s.Text
t.Story.Words.First.Replace "This will replace the first word " & _
  "with this text " 
End Sub