Share via


Range.Move Method

Collapses the specified range or selection to its start or end position and then moves the collapsed object by the specified number of units.

Namespace:  Microsoft.Office.Interop.Word
Assembly:  Microsoft.Office.Interop.Word (in Microsoft.Office.Interop.Word.dll)

Syntax

'Declaration
Function Move ( _
    ByRef Unit As Object, _
    ByRef Count As Object _
) As Integer
'Usage
Dim instance As Range
Dim Unit As Object
Dim Count As Object
Dim returnValue As Integer

returnValue = instance.Move(Unit, Count)
int Move(
    ref Object Unit,
    ref Object Count
)

Parameters

  • Unit
    Type: System.Object%
    Optional Object. The unit by which the collapsed range or selection is to be moved. Can be one of the following WdUnits constants: wdCharacter, wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow, or wdTable. If expression returns a Selection object, you can also use wdLine. The default value is wdCharacter.
  • Count
    Type: System.Object%
    Optional Object. The number of units by which the specified range or selection is to be moved. If Count is a positive number, the object is collapsed to its end position and moved backward in the document by the specified number of units. If Count is a negative number, the object is collapsed to its start position and moved forward by the specified number of units. The default value is 1. You can also control the collapse direction by using the Collapse method before using the Move method. If the range or selection is in the middle of a unit or isn't collapsed, moving it to the beginning or end of the unit counts as moving it one full unit.

Return Value

Type: System.Int32

Remarks

This method returns a Integer value that indicates the number of units by which the object was actually moved, or it returns 0 (zero) if the move was unsuccessful.

The start and end positions of a collapsed range or selection are equal.

Applying the Move method to a range doesn't rearrange text in the document. Instead, it redefines the range to refer to a new location in the document.

See Also

Reference

Range Interface

Range Members

Microsoft.Office.Interop.Word Namespace