Selection.MoveRight 方法 (Word)Selection.MoveRight method (Word)

将选定内容向右移动,并返回已移动的单位数。Moves the selection to the right and returns the number of units it has been moved.


expressionexpression. MoveRight( _Unit_ , _Count_ , _Extend_ )

expression:必需。expression Required. 表示 Selection 对象的变量。A variable that represents a Selection object.


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
UnitUnit 可选Optional WdUnitsWdUnits 移动选定内容时所基于的单位。默认值为 wdCharacterThe unit by which the selection is to be moved.The default value is wdCharacter.
CountCount 可选Optional VariantVariant 选定内容移动的单位数。The number of units the selection is to be moved. 默认值为 1。The default value is 1.
ExtendExtend 可选Optional VariantVariant 可以是 wdMove,也可以是 wdExtendCan be either wdMove or wdExtend. 如果使用的是 wdMove,则先把选定内容折叠到端点,再移到右侧。If wdMove is used, the selection is collapsed to the endpoint and moved to the right. 如果使用的是 wdExtend,则将选定内容扩展到右侧。If wdExtend is used, the selection is extended to the right. 默认值是 wdMoveThe default value is wdMove.

返回值Return value



如果 Unit 为 wdCell ,则 Extend 参数只能是 wdMoveWhen the Unit is wdCell, the Extend argument can only be wdMove.


下面的示例先将选定内容移到上一个字段前面,再选择此字段。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. 如果移动成功,MoveRight 返回 1。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 对象Selection Object

支持和反馈Support and feedback

有关于 Office VBA 或本文档的疑问或反馈?Have questions or feedback about Office VBA or this documentation? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.