Table of contents
TOC
Collapse the table of content
Expand the table of content

TextRange.Lines Method (Publisher)

office 365 dev account|Last Updated: 8/24/2017
|
3 Contributors

Returns a TextRange object that represents the specified lines.

Syntax

expression. Lines( Start, Length)

_expression_A variable that represents a TextRange object.

Parameters

NameRequired/OptionalData TypeDescription
StartRequiredLongThe first line in the returned range.
LengthOptionalLongThe number of lines to be returned. Default is 1.

Return Value

TextRange

Remarks

If Start is greater than the number of lines in the specified text, the returned range starts with the last line in the specified range.

If Length is greater than the number of lines from the specified starting line to the end of the text, the returned range contains all those lines.

Example

This example replaces the first three lines of the first shape on the first page with the specified string.

Sub ReplaceLines() 
 Dim rngText As TextRange 
 Set rngText = ActiveDocument.Pages(1).Shapes(1) _ 
 .TextFrame.TextRange.Lines(Start:=1, Length:=3) 

 rngText.Text = "This is replacement text." &; vbCrLf 

End Sub
© 2018 Microsoft