Visio) (Document.AddUndoUnit 方法

將支援 IOleUndoUnit 或 IVBUndoUnit 介面的物件新增至 Microsoft Visio 復原佇列。

語法

運算式。AddUndoUnit (pUndoUnit)

運算式 代表 Document 物件的變數。

參數

名稱 必要/選用 資料類型 描述
pUndoUnit 必要 [未知] 物件的參考,此物件會支援 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 支援與意見反應。