Publisher) (Document.Redo 方法

Redoes the last action or a specified number of actions. 对应于 Standard 工具栏上“重做”按钮旁边的箭头时显示的项列表。 调用此方法会反向执行撤 消 方法。

语法

表达式。重做 (计数)

表达式 表示 Document 对象的变量。

参数

名称 必需/可选 数据类型 说明
Count 可选 Long 指定要恢复的操作数量。 默认值为 1,表示如果省略该参数,则仅恢复上一步操作。

返回值

Nothing

注解

如果在重做堆栈上没有操作时调用,或者当 Count 大于当前驻留在堆栈上的操作数时, 重做 方法将重做尽可能多的操作,并忽略其余操作。

一次调用 Redo 最多可恢复 20 个操作。

示例

以下示例使用 Redo 方法恢复使用 Undo 方法撤消的操作的子集。

第 1 部分在当前出版物的第四页上创建一个包含文字框架的矩形。 设置不同的字体属性,并且将文字添加到文字框架。 在此例中,文字"This font is Courier"被设为 12 磅加粗的 Courier 字体。

第二部分测试文本框架中的文字是否 Verdana 字体。 如果不是,则使用 “ 撤消 ”方法撤消撤消堆栈上的最后四个操作。 然后使用 Redo 方法重做刚刚撤消的最后四个操作中的前两个。 在这种情况下,第三个操作 (设置字体大小) 和第四个操作 (设置字体为加粗) 被恢复。 字体名称将变为宋体,并在修改的文本。

Dim thePage As page 
Dim theShape As Shape 
Dim theDoc As Publisher.Document 
 
Set theDoc = ActiveDocument 
Set thePage = theDoc.Pages(4) 
 
' Part 1 
With theDoc 
 With thePage 
 ' Setting the shape creates the first action 
 Set theShape = .Shapes.AddShape(msoShapeRectangle, _ 
 75, 75, 190, 30) 
 ' Setting the text range creates the second action 
 With theShape.TextFrame.TextRange 
 ' Setting the font size creates the third action 
 .Font.Size = 12 
 ' Setting the font to bold creates the fourth action 
 .Font.Bold = msoTrue 
 ' Setting the font name creates the fifth action 
 .Font.Name = "Courier" 
 ' Setting the text creates the sixth action 
 .Text = "This font is Courier." 
 End With 
 End With 
 
 ' Part 2 
 If Not thePage.Shapes(1).TextFrame.TextRange.Font.Name = "Verdana" Then 
 .Undo (4) 
 With thePage 
 With theShape.TextFrame.TextRange 
 ' Redo redoes the first two of the four actions that were just undone 
 theDoc.Redo (2) 
 .Font.Name = "Verdana" 
 .Text = "This font is Verdana." 
 End With 
 End With 
 End If 
End With

支持和反馈

有关于 Office VBA 或本文档的疑问或反馈? 请参阅 Office VBA 支持和反馈,获取有关如何接收支持和提供反馈的指南。