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

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

语法Syntax

expressionexpression. MoveLeft( _Unit_ , _Count_ , _Extend_ )

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

参数Parameters

名称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 left. 如果使用了 wdExtend ,则所选内容向左扩展。If wdExtend is used, the selection is extended to the left. 默认值为 wdMoveThe default value is wdMove.

备注Remarks

当单元是wdCell时, Extend 参数将仅为wdMoveWhen the Unit is wdCell, the Extend argument will only be wdMove.

示例Example

本示例将选定内容向左移动一个字符。This example moves the selection one character to the left. 如果移动成功,则 MoveLeft 方法返回 1。If the move is successful, MoveLeft returns 1.

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

本示例激活选定域的域底纹功能,插入 DATE 域,然后将选定内容向左移动,以选定该域。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

另请参阅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.