This example moves the selection two words to the right and positions the insertion point after the second word's trailing space. If the move is unsuccessful, a message box indicates that the selection is at the end of the document.
If Selection.StoryType = wdMainTextStory Then
wUnits = Selection.Move(Unit:=wdWord, Count:=2)
If wUnits < 2 Then _
MsgBox "Selection is at the end of the document"
End If
This example sets Range1
to the first paragraph in the active document and then moves the range forward three paragraphs. After this macro is run, the insertion point is positioned at the beginning of the fourth paragraph.
Set Range1 = ActiveDocument.Paragraphs(1).Range
With Range1
.Collapse Direction:=wdCollapseStart
.Move Unit:=wdParagraph, Count:=3
.Select
End With
This example moves the selection forward three cells in the table.
If Selection.Information(wdWithInTable) = True Then
Selection.Move Unit:=wdCell, Count:=3
End If
This example starts the Calculator application (Calc.exe) and uses the Move method to reposition the application window.
Shell "Calc.exe"
With Tasks("Calculator")
.WindowState = wdWindowStateNormal
.Move Top:=50, Left:=50
End With