Document.EndCustomUndoAction 方法 (Publisher)

指定要将其合并以创建单项撤消操作的一组操作的结束点。 BeginCustomUndoAction 方法用于指定起始点和标签 (文本说明) 用于创建单个撤消操作的操作。 可以使用单项撤消操作将合并的操作组撤消。

语法

表达式EndCustomUndoAction

表达 一个代表 Document 对象的变量。

备注

调用 EndCustomUndoAction 方法之前,必须调用 BeginCustomUndoAction 方法。 如果 EndCustomUndoActionBeginCustomUndoAction 之前调用,则返回运行时错误。

示例

下面的示例包含两个自定义撤消操作。 第一个是在活动出版物的第四页上创建的。 BeginCustomUndoAction 方法用于指定何时开始执行自定义撤消操作的点。 六个单个操作执行,然后包装成通过 EndCustomUndoAction 调用一个操作。

然后测试在第一个自定义撤消操作中创建的文本框架中的文字,以确定字体是否为 Verdana。 如果不是,则调用 Undo 方法,并将 UndoActionsAvailable 作为参数进行传递。 在这种情况下,只有一项撤消操作可用。 因此,调用 Undo 方法将只撤消一项操作,但此操作已将六项操作合并为一项。

然后创建第二个撤消操作,并且还可以在以后使用单个撤消操作将其撤消。

本示例假定当前出版物至少包含四页。

Dim thePage As page 
Dim theShape As Shape 
Dim theDoc As Publisher.Document 
 
Set theDoc = ActiveDocument 
Set thePage = theDoc.Pages(4) 
 
With theDoc 
 ' The following six of actions are wrapped to create one 
 ' custom undo action named "Add Rectangle and Courier Text". 
 .BeginCustomUndoAction ("Add Rectangle and Courier Text") 
 With thePage 
 Set theShape = .Shapes.AddShape(msoShapeRectangle, _ 
 75, 75, 190, 30) 
 With theShape.TextFrame.TextRange 
 .Font.Size = 14 
 .Font.Bold = msoTrue 
 .Font.Name = "Courier" 
 .Text = "This font is Courier." 
 End With 
 End With 
 .EndCustomUndoAction 
 
 If Not thePage.Shapes(1).TextFrame.TextRange.Font.Name = "Verdana" Then 
 ' This call to Undo will undo all actions that are available. 
 ' In this case, there is only one action that can be undone. 
 .Undo (.UndoActionsAvailable) 
 ' A new custom undo action is created with a name of 
 ' "Add Balloon and Verdana Text". 
 .BeginCustomUndoAction ("Add Balloon and Verdana Text") 
 With thePage 
 Set theShape = .Shapes.AddShape(msoShapeBalloon, _ 
 75, 75, 190, 30) 
 With theShape.TextFrame.TextRange 
 .Font.Size = 11 
 .Font.Name = "Verdana" 
 .Text = "This font is Verdana." 
 End With 
 End With 
 .EndCustomUndoAction 
 End If 
End With

支持和反馈

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