MoveLeft Method

Microsoft Word Visual Basic

Moves the selection to the left and returns the number of units it's been moved.

expression.MoveLeft(Unit, Count, Extend)

expression    Required. An expression that returns a Selection object.

Unit    Optional WdUnits. The unit by which the selection is to be moved.

Can be one of the following WdUnits constants.

wdCell

wdCharacter

wdWord

wdSentence

The default value is wdCharacter.

Count    Optional Variant. The number of units the selection is to be moved. The default value is 1.

Extend    Optional Variant. Can be either wdMove or wdExtend. If wdMove is used, the selection is collapsed to the end point and moved to the left. If wdExtend is used, the selection is extended to the left. The default value is wdMove.

Remarks

When the Unit is wdCell, the Extend argument will only be wdMove.

Example

This example moves the selection one character to the left. If the move is successful, MoveLeft returns 1.

If Selection.MoveLeft = 1 Then MsgBox "Move was successful"
		

This example enables field shading for the selected field, inserts a DATE field, and then moves the selection left to select the field.

ActiveDocument.ActiveWindow.View.FieldShading = _
    wdFieldShadingWhenSelected
With Selection
    .Fields.Add Range:=Selection.Range, Type:=wdFieldDate
    .MoveLeft Unit:=wdWord, Count:=1
End With
		

This example moves the selection to the previous table cell.

If Selection.Information(wdWithInTable) = True Then
    Selection.MoveLeft Unit:=wdCell, Count:=1, Extend:=wdMove
End If