Previous Document Next Document
TextRange.Collapse

Sub Collapse([ToEnd As Boolean = True])

Member of TextRange

The Collapse method collapses the text range.

Parameters
Description
ToEnd
This parameter is optional, and its default value is True.

The following code 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 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.