TextRange.Move method (Publisher)
Collapses the specified range to its start position or end position, and then moves the collapsed object by the specified number of units. This method returns a Long that represents the number of units by which the object was actually moved, or it returns 0 (zero) if the move was unsuccessful.
Syntax
expression.Move (Unit, Size)
expression A variable that represents a TextRange object.
Parameters
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 by which the specified range or selection is to be moved. If Size is a positive number, the object is collapsed to its end position and moved forward in the document by the specified number of units. If Size is a negative number, the object is collapsed to its start position and moved backward by the specified number of units. You can also control the collapse direction by using the Collapse method before using the Move method. |
Return value
Long
Example
This example collapses the specified range and inserts a new sentence at the beginning of the range.
Sub MoveText()
Dim rngText As TextRange
Set rngText = ActiveDocument.Pages(1).Shapes(1).TextFrame _
.TextRange.Words(Start:=1, Length:=5)
With rngText
.Move Unit:=pbTextUnitParagraph, Size:=-1
.Text = "This adds new text to the beginning of the range. "
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.
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for