Share via


MoveEnd Method [Publisher 2003 VBA Language Reference]

Moves the ending character position of a range. This method returns a Long that represents the number of units the range or selection actually moved or returns 0 (zero) if the move was unsuccessful.

expression.MoveEnd(Unit, Size)

expression Required. An expression that returns one of the objects in the Applies To list.

PbTextUnit

PbTextUnit can be one of these PbTextUnit constants.
pbTextUnitCell
pbTextUnitCharacter
pbTextUnitCharFormat
pbTextUnitCodePoint
pbTextUnitColumn
pbTextUnitLine
pbTextUnitObject
pbTextUnitParaFormat
pbTextUnitParagraph
pbTextUnitRow
pbTextUnitScreen
pbTextUnitSection
pbTextUnitSentence
pbTextUnitStory
pbTextUnitTable
pbTextUnitWindow
pbTextUnitWord

Size  Required Long. The number of units to move. If this number is positive, the ending character position is moved forward in the document. If this number is negative, the end is moved backward. If the ending position overtakes the starting position, the range collapses and both character positions move together.

Remarks

Use the MoveStart method to move the starting character position for a range.

Example

This example sets a text range, moves the range's starting and ending character positions, and then formats the font for the range.

Sub MoveStartEnd()
    Dim rngText As TextRange

    Set rngText = ActiveDocument.Pages(1).Shapes(1).TextFrame _
        .TextRange.Paragraphs(Start:=3, Length:=1)

    With rngText
        .MoveStart Unit:=pbTextUnitLine, Size:=-2
        .MoveEnd Unit:=pbTextUnitLine, Size:=1
        With .Font
            .Bold = msoTrue
            .Size = 15
        End With
    End With

End Sub

Applies to | TextRange Object