Undoes the last action or a specified number of actions. 對應至當您選擇 Standard 工具列上 [復原] 按鈕旁的箭號時顯示的項目清單。
語法
運算式。復原 (計數)
運算式 代表 Document 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| Count | 選用 | Long | 會指定要復原的動作數目。 預設值為 1,這表示若省略,則只會復原上一個動作。 |
註解
如果在復原堆疊上沒有任何動作,或 Count 大於目前位於堆疊上的動作數時呼叫, Undo 方法會盡可能復原更多的動作,並忽略其餘的動作。
呼叫 Undo 一次,最多可復原 20 個動作。
範例
下列範例使用 Undo 方法來復原不符合特定準則的動作。
本範例的第一部分將矩形圖說文字圖案新增到使用中出版物的第四頁,並將文字新增到此圖說文字。 此程序會建立三個動作。
此範例第 2 部分測試新增到圖說文字的文字的字型是否為新細明體。 否則會使用 Undo 方法來復原所有可用的動作, (使用 UndoActionsAvailable 屬性的值來指定復原所有動作) 。 這會清除從堆疊的所有動作。 接著會新增新的矩形圖案和文字框,且文字框會填入 Verdana 文字。
Dim thePage As page
Dim theShape As Shape
Dim theDoc As Publisher.Document
Set theDoc = ActiveDocument
Set thePage = theDoc.Pages(4)
With theDoc
' Part 1
With thePage
' Setting the shape creates the first action
Set theShape = .Shapes.AddShape(msoShapeRectangularCallout, _
75, 75, 120, 30)
' Setting the text range creates the second action
With theShape.TextFrame.TextRange
' Setting the text creates the third action
.Text = "This text is not Verdana."
End With
End With
' Part 2
If Not thePage.Shapes(1).TextFrame.TextRange.Font.Name = "Verdana" Then
' UndoActionsAvailable = 3
.Undo (.UndoActionsAvailable)
With thePage
Set theShape = .Shapes.AddShape(msoShapeRectangle, _
75, 75, 120, 30)
With theShape.TextFrame.TextRange
.Font.Name = "Verdana"
.Text = "This text is Verdana."
End With
End With
End If
End With
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。