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

移动指定的所选内容的起始位置。Moves the start position of the specified selection.

语法Syntax

expressionexpression. MoveStart( _Unit_ , _Count_ )

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

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
UnitUnit 可选Optional WdUnitsWdUnits 起始位置指定所选内容的单位将被移动。The unit by which start position of the specified selection is to be moved. 可以是常量之一。Can be one of the WdUnits constants. 默认值是 wdCharacterThe default value is wdCharacter.
CountCount 可选Optional VariantVariant 指定的所选内容要移动的最大单位数。The maximum number of units by which the specified selection is to be moved. 如果 Count 为正数,则所选内容的起始位置在文档中向前移动。If Count is a positive number, the start position of the selection is moved forward in the document. 如果为负数,则起始位置向后移动。If it is a negative number, the start position is moved backward. 如果起始位置向前移至结束位置之前,则折叠所选内容,并将起始位置和结束位置移至同一位置。If the start position is moved forward to a position beyond the end position, the selection is collapsed and both the start and end positions are moved together. 默认值为 1。The default value is 1.

返回值Return value

整数Integer

备注Remarks

此方法返回一个整数,该整数表明起始位置或该所选内容实际移动的单位数,如果移动不成功,则此方法返回 0(零)。This method returns an integer that indicates the number of units by which the start position or the selection actually moved, or it returns 0 (zero) if the move was unsuccessful.

示例Example

以下示例将所选内容的起始位置向前移动一个字符(即所选内容减少一个字符)。This example moves the start position of the selection one character forward (the selection size is reduced by one character). 注意,一个空格算作一个字符。Note that a space is considered a character.

Selection.MoveStart Unit:=wdCharacter, Count:=1

以下示例将所选内容的起始位置移至该行的开头(所选内容扩展到行的开头)。This example moves the start position of the selection to the beginning of the line (the selection is extended to the start of the line).

Selection.MoveStart Unit:=wdLine, Count:=-1

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