TextRange.MoveEnd method (Publisher)

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


expression.MoveEnd (Unit, Size)

expression A variable that represents a TextRange object.


Name Required/Optional Data type Description
Unit Required PbTextUnit The unit by which the collapsed range or selection is to be moved. Can be one of the PbTextUnit constants declared in the Microsoft Publisher type library.
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.

Return value



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

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.