Skip to content

Latest commit

 

History

History
85 lines (48 loc) · 2 KB

Word.Selection.MoveRight.md

File metadata and controls

85 lines (48 loc) · 2 KB
title keywords f1_keywords api_name ms.assetid ms.date ms.localizationpriority
Selection.MoveRight method (Word)
vbawd10.chm158663157
vbawd10.chm158663157
Word.Selection.MoveRight
fcac96c7-7189-87b2-d800-9d161edb1e09
06/08/2017
medium

Selection.MoveRight method (Word)

Moves the selection to the right and returns the number of units it has been moved.

Syntax

expression. MoveRight( _Unit_ , _Count_ , _Extend_ )

expression Required. A variable that represents a Selection object.

Parameters

Name Required/Optional Data type Description
Unit Optional WdUnits The unit by which the selection is to be moved.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 endpoint and moved to the right. If wdExtend is used, the selection is extended to the right. The default value is wdMove.

Return value

Long

Remarks

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

Example

This example moves the selection before the previous field and then selects the field.

With Selection 
 Set MyRange = .GoTo(wdGoToField, wdGoToPrevious) 
 .MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend 
 If Selection.Fields.Count = 1 Then Selection.Fields(1).Update 
End With

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

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

This example moves the selection to the next table cell.

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

See also

Selection Object

[!includeSupport and feedback]