DocumentBase.Redo(Object) 方法

定义

执行已撤消的上一个操作(与 Undo(Object) 方法相反)。

public bool Redo (ref object times);

参数

times
Object

要重复的操作的数目。

返回

Boolean

如果操作已成功重复,则为 true

示例

下面的代码示例向文档中添加了三个单词,两次调用 undo 方法,然后调用 redo 方法一次。 文档中保留了两个单词。 若要使用此示例,请在 ThisDocument 文档级项目的类中运行它。

private void DocumentRedo()
{
    object undoTime = 2;
    object redoTime = 1;
    this.Paragraphs[1].Range.InsertParagraphBefore();
    
    this.Application.Selection.TypeText("New ");
    this.Application.Selection.TypeText("text ");
    this.Application.Selection.TypeText("here.");

    this.Undo(ref undoTime);
    this.Redo(ref redoTime);
}
Private Sub DocumentRedo()
    Dim undoTime As Object = 2
    Dim redoTime As Object = 1
    Me.Paragraphs(1).Range.InsertParagraphBefore()

    Me.Application.Selection.TypeText("New ")
    Me.Application.Selection.TypeText("text ")
    Me.Application.Selection.TypeText("here.")

    Me.Undo(undoTime)
    Me.Redo(redoTime)
End Sub 

注解

可选参数

有关可选参数的信息,请参阅Office 解决方案中的可选参数

适用于