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

将所选内容向上移动,并返回移动的单位数。Moves the selection up and returns the number of units that it has been moved.

语法Syntax

表达式MoveUp(单元计数扩展)expression.MoveUp (Unit, Count, Extend)

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

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
UnitUnit 可选Optional VariantVariant 要移动所选区域单位。The unit by which to move the selection. 可以是下列的常量之一: wdLinewdParagraphwdWindowwdScreenCan be one of the following WdUnits constants: wdLine, wdParagraph, wdWindow or wdScreen. 默认值是 wdLineThe default value is wdLine. 设备参数的 wdWindow 常量可用于移动到顶部或底部的活动窗口。You can use the wdWindow constant for the Unit argument to move to the top or bottom of the active window. 无论 Count 的值 (大于1或小于-1), wdWindow常量仅移动一个单位。Regardless of the value of Count (greater than 1 or less than -1), the wdWindow constant moves only one unit. 使用 wdScreen 常量可以移动多个屏幕。Use the wdScreen constant to move more than one screen.
CountCount 可选Optional VariantVariant 选定内容移动的单位数。The number of units the selection is to be moved. 默认值为 1。The default value is 1.
ExtendExtend 可选Optional VariantVariant 指定是移动还是扩展所选内容。Specifies whether the selection is moved or extended. 可以是 wdMove,也可以是 wdExtendCan be either wdMove or wdExtend. 如果使用 wdMove ,则所选内容折叠到结束并向上移动。If wdMove is used, the selection is collapsed to the endpoint and moved up. 如果使用了 wdExtend ,则所选内容向上扩展。If wdExtend is used, the selection is extended up. 默认值为 wdMoveThe default value is wdMove.

返回值Return value

LongLong

示例Example

本示例将选定内容移至前一个段落的开头。This example moves the selection to the beginning of the previous paragraph.

Selection.MoveRight 
Selection.MoveUp Unit:=wdParagraph, Count:=2, Extend:=wdMove

本示例显示当前行号,将选定内容向上移动三行,并再次显示当前行号。This example displays the current line number, moves the selection up three lines, and displays the current line number again.

MsgBox "Line " & Selection.Information(wdFirstCharacterLineNumber) 
Selection.MoveUp Unit:=wdLine, Count:=3, Extend:=wdMove 
MsgBox "Line " & Selection.Information(wdFirstCharacterLineNumber)

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