VERSION 1.0 CLASS BEGIN MultiUse = -1 'True END Attribute VB_Name = "API_UndoWrapper" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = False Attribute VB_Exposed = False ' ====== Class for managing Visio undo scopes ========== ' Shared module version: 20210329 ' Tested in: TestVisio ' Depends on: ' Required reference: Option Explicit Private app_ As Visio.Application Private scopeID_ As Long Private isActive_ As Boolean Private Sub Class_Initialize() scopeID_ = 0 isActive_ = False End Sub Public Function Init(targetApp As Visio.Application) Set app_ = targetApp End Function Public Function BeginScope(sName$) If isActive_ Then Debug.Print "Scope already running" Exit Function Else isActive_ = True scopeID_ = app_.BeginUndoScope(sName) End If End Function Public Function EndScope(Optional bCommit As Boolean = True) If isActive_ Then isActive_ = False Call app_.EndUndoScope(scopeID_, bCommit) End If End Function