共用方式為


Publisher) (Document.EndCustomUndoAction 方法

會指定一組動作的終點,這些動作會被包起來以建立一個單一的復原動作。 BeginCustomUndoAction方法可用來指定建立單一復原動作之動作的起點和標籤 (文字描述) 。 只要一次的復原動作,就可復原包起來的動作群組。

語法

運算式EndCustomUndoAction

表達 代表 Document 物件的變數。

註解

EndCustomUndoAction 方法被呼叫之前必須呼叫 BeginCustomUndoAction 方法。 如果 EndCustomUndoAction 呼叫之前 BeginCustomUndoAction 會傳回執行時期錯誤。

範例

下列範例會包含兩個自訂復原動作。 第一個會建立使用中出版物第四頁上。 BeginCustomUndoAction 方法用來指定自訂復原動作應該開始的點。 執行六個個別的動作,並將一個巨集指令且 EndCustomUndoAction 呼叫的包裝然後。

接著會測試在第一個自訂復原動作中建立的文字框文字,以判定字型是否為 Verdana。 如果不是,將以做為參數傳遞的 UndoActionsAvailable 呼叫 Undo 方法。 在這種情況下,只有一個復原動作可用。 因此,呼叫 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 支援與意見反應