API Documentation > CorelDRAW > 2025-v26 > TextRange > IVGTextRange
TextRange.Collapse method
Collapses the text range
Syntax:
Sub Collapse(Optional ByVal ToEnd As Boolean = True)
Parameters:
Name Type Description
ToEnd
Boolean
Remarks:
The Collapse method collapses a text range.
Examples:
The following VBA example displays the positions of the starting and ending characters of the text range before and after the text is collapsed. It then inserts text and applies bold formatting to the inserted text.
Sub Test()
Dim t As Text
Dim s As Shape
Dim tr As TextRange
Dim d As Document
Set d = CreateDocument
Set s = d.ActiveLayer.CreateParagraphText(2, 2, 4, 4, "This is an example.")
Set t = s.Text
Set tr = t.Story.Words(2, 2)
MsgBox "The text range is from " & tr.Start & " to " & tr.End & " Characters"
tr.Collapse
MsgBox "The text range is from " & tr.Start & " to " & tr.End & " Characters"
tr.Text = " This will be inserted at the current position. "
tr.Bold = True 
End Sub