Move method as it applies to the TextRange object.
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.
expression.Move(Unit, Size)
expression Required. An expression that returns one of the above objects.
Unit Required PbTextUnit. The unit by which the collapsed range or selection is to be moved.
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 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.
Move method as it applies to the Window object.
Moves the active document window.
expression.Move(Left, Top)
expression Required. An expression that returns one of the above objects.
Left Required Long. The horizontal screen position of the specified window.
Top Required Long. The vertical screen position of the specified window.
If the application window is either maximized or minimized, this method will return an error.
As it applies to the TextRange object.
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
As it applies to the Window object.
This example checks the state of the application window, and if it is neither maximized nor minimized, moves the window to the upper left corner of the screen.
Sub MoveWindow()
With ActiveWindow
If .WindowState = pbWindowStateNormal Then
.Move Left:=50, Top:=50
End If
End With
End Sub