新增一個支援 IOleUndoUnit 或 IVBUndoUnit 介面的物件,加入 Microsoft Visio 的復原隊列。
語法
表情。AddUndoUnit (pUndoUnit)
詞 一個代表 文件 物件的變數。
參數
| 名稱 | 必要/選用 | 資料類型 | 描述 |
|---|---|---|---|
| pUndo單元 | 必要 | [未知] | 物件的參考,此物件會支援 IOleUndoUnit 或 IVBUndoUnit 介面。 |
傳回值
無
註解
如需在物件上實作 IOleUndoUnit 介面的詳細資訊,請參閱 MSDN 網站上的 Microsoft Platform SDK。 如需實作 IVBUndoUnit 介面的詳細資訊,請參閱 MSDN 上的<開發 Microsoft Visio 解決方案>(英文)。
範例
以下程序說明如何使用 AddUndoUnit 方法將物件加入 Visio 的復原隊列。 當一個形狀被加入活動文件時,程序會檢查該形狀是因為復原或重做動作而新增,若不是,則會新增一個復原單元。
此程序屬於 clsParticipateInUndo 類別,該類別定義於 Visio SDK 程式碼範例庫中的兩個相關類別模組之一,且不設計為獨立執行。 (另一個類別模組定義了類別 clsVBUndoUnits.) 欲了解更多關於這些類別模組的資訊,請參閱 MSDN 上的 Visio SDK。
Private Sub mvsoDocument_ShapeAdded(ByVal vsoShape As IVShape)
Dim VBUndoUnit As clsVBUndoUnits
On Error GoTo mvsoDocument_ShapeAdded_Err
If Not (mvsoApplication Is Nothing) Then
If Not msvoApplication.IsUndoingOrRedoing Then
'Increment the count of undoable actions.
IncrementModuleVar
Debug.Print "Original Do: GetModuleVar = " & GetModuleVar
'Instantiate clsVBUndoUnit, a
'class that implements Visio.IVBUndoUnit.
Set VBUndoUnit = New clsVBUndoUnits
'Pass the current instance of the class
'of which this procedure is a member,
'clsParticipateInUndo, to the Undo unit.
VBUndoUnit.SetModelObject Me
'Add an Undo unit.
mvsoApplication.AddUndoUnit VBUndoUnit
End If
End If
Exit Sub
mvsoDocument_ShapeAdded_Err:
MsgBox Err.Description
End Sub
支援和意見反應
有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應。