Global.Repeat 方法 (Word)Global.Repeat method (Word)

重复最近的编辑操作一个或更多的时间。Repeats the most recent editing action one or more times. 如果成功地重复这些命令,则返回TrueReturns True if the commands were repeated successfully.

语法Syntax

expressionexpression. Repeat( _Times_ )

_表达式_代表全局对象的变量。expression A variable that represents a 'Global' object. 可选。Optional.

参数Parameters

名称Name 必需/可选Required/Optional 数据类型Data type 说明Description
TimesTimes 可选Optional VariantVariant 要重复上一个命令的次数。The number of times you want to repeat the last command.

返回值Return value

布尔值Boolean

备注Remarks

使用此方法等效于使用编辑菜单上的重复命令。Using this method is the equivalent to using the Repeat command on the Edit menu.

示例Example

以下示例先插入文本"Hello"接着插入两个段落(重复一次第二个键入操作)。This example inserts the text "Hello" followed by two paragraphs (the second typing action is repeated once).

Selection.TypeText "Hello" 
Selection.TypeParagraph 
Repeat

本示例重复三次最后的命令(如果该命令可以重复的话)。This example repeats the last command three times (if it can be repeated).

On Error Resume Next 
If Repeat(3) = True Then StatusBar = "Action repeated"

另请参阅See also

全局对象Global Object