Application.AddUndoUnit 方法 (Visio)

将支持 IOleUndoUnitIVBUndoUnit 接口的对象添加到 Microsoft Visio 撤消队列。

语法

表达式AddUndoUnit (pUndoUnit)

expression:表示 Application 对象的变量。

参数

名称 必需/可选 数据类型 说明
pUndoUnit 必需 [未知] 对支持 IOleUndoUnitIVBUndoUnit 接口的对象的引用。

返回值

Nothing

注解

有关在对象上实现 IOleUndoUnit 接口的信息,请参阅 Microsoft 平台 SDK。 有关实现 IVBUndoUnit 接口的信息,请参阅 开发 Microsoft Visio 解决方案

示例

以下过程显示如何使用 AddUndoUnit 方法将对象添加到 Visio 撤消队列。 在将某个形状添加到活动文档时,该过程会检查该形状是否是作为撤消或恢复动作的结果添加的,如果不是,该过程将添加一个撤消单元。

该过程是 clsParticipateInUndo 类的成员,该类是在 Visio SDK 示例代码库的两个相关类模块之一中定义的,并且不能独立运行。 (另一个类模块定义类 clsVBUndoUnits.) 有关这些类模块的详细信息,请参阅 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 支持和反馈,获取有关如何接收支持和提供反馈的指南。