Previous Document Next Document

Object Model Reference : Classes : T : TextRange : Methods : TextRange.Collapse


TextRange.Collapse

Sub Collapse([ToEnd As Boolean = True])

Description

Member of TextRange

The Collapse method collapses a text range.

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

VBA example

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

Previous Document Next Document Back to Top

Copyright 2013 Corel Corporation. All rights reserved.