Document.Undo 方法 (Publisher)
Undoes the last action or a specified number of actions. 對應至當您選擇[標準] 工具列上 [復原] 按鈕旁邊的箭號時所顯示的專案清單。
語法
運算式。復原 (計數)
表達 代表 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 支援與意見反應。