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

移动指定的所选内容,直到在文档中找到一个指定的字符。Moves the specified selection until one of the specified characters is found in the document.


expressionexpression. MoveUntil( _Cset_ , _Count_ )

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


名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
CsetCset 必需Required VariantVariant 一个或多个字符。One or more characters. 如果在 Count 值终止之前找到了 Cset 中的任何字符,则指定的所选内容作为插入点紧靠在该字符之前放置。If any character in Cset is found before the Count value expires, the specified selection is positioned as an insertion point immediately before that character. 此参数区分大小写。This argument is case-sensitive.
CountCount 可选Optional VariantVariant 最大指定所选内容的移动的字符数。The maximum number of characters by which the specified selection is to be moved. 可以是一个数字, 也可以是wdForwardwdBackward常量。Can be a number or either the wdForward or wdBackward constant. 如果 Count 是一个正数,则所选内容在文档中从结束位置开始向前移动。If Count is a positive number, the selection is moved forward in the document, beginning at the end position. 如果是负数,选定内容是从开始位置开始向后移动。If it is a negative number, the selection is moved backward, beginning at the start position. 默认值是 wdForwardThe default value is wdForward.


此方法返回指定的所选内容移动的字符数, 作为Long值。This method returns the number of characters by which the specified selection was moved, as a Long value. 如果 Count 值大于 0 (零),则此方法返回数移动字符加一。If Count is greater than 0 (zero), this method returns the number of characters moved plus one. 如果 Count 小于 0 (零),则此方法返回移动的字符的数。If Count is less than 0 (zero), this method returns the number of characters moved minus one. 如果没有找到 Cset 字符,则不改变所选内容,该方法返回 0 (零)。If no Cset characters are found, the selection isn't not changed and the method returns 0 (zero).


以下示例将所选内容移至活动段落的末尾,然后显示所选内容移动的字符数。This example moves the selection forward to the end of the active paragraph and then displays the number of characters by which the selection was moved.

x = Selection.MoveUntil(Cset:=Chr$(13), Count:=wdForward) 
MsgBox x-1 & " character positions were moved"

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