You can disable the undo cache at the application level:
Visio.Application.UndoEnabled = False (or C++ equivalent...)
For creating an undo block, you wrap your code in an "undo scope"
Visio.Application.BeginUndoScope
Visio.Application.EndUndoScope
Below is the VBA sample that comes in the developer reference that ships
with Visio for a sample. You can get at it through VBA (Alt+F11)
--
Hope this helps,
Chris Roth
Visio MVP
--------------------------------------------------------------------------------------
Private WithEvents vsoApplication As Visio.Application
Private lngScopeID As Long
Public Sub EndUndoScope_Example()
Dim vsoShape As Visio.Shape
'Set the module-level application variable to
'trap Application-level events.
Set vsoApplication = Visio.Application
'Begin a scope and set the module-level variable.
lngScopeID = vsoApplication.BeginUndoScope("Draw Shapes")
'Draw three shapes.
Set vsoShape = ActivePage.DrawRectangle(1, 2, 2, 1)
ActivePage.DrawOval 3, 4, 4, 3
ActivePage.DrawLine 4, 5, 5, 4
'Change a cell to trigger a CellChanged event.
vsoShape.Cells("Width").Formula = 5
'End and commit this scope.
vsoApplication.EndUndoScope lngScopeID, True
End Sub
Private Sub vsoApplication_CellChanged(ByVal Cell As IVCell)
'Check to see if this cell change is the result of something
'happening within the scope.
If vsoApplication.IsInScope(lngScopeID) Then
Debug.Print Cell.Name & " changed in scope "; lngScopeID
End If
End Sub
Private Sub vsoApplication_EnterScope(ByVal app As IVApplication, _
ByVal nScopeID As Long, _
ByVal bstrDescription As
String)
If vsoApplication.CurrentScope = lngScopeID Then
Debug.Print "Entering my scope " & nScopeID
Else
Debug.Print "Enter Scope " & bstrDescription & "(" & nScopeID & ")"
End If
End Sub
Private Sub vsoApplication_ExitScope(ByVal app As IVApplication, _
ByVal nScopeID As Long, _
ByVal bstrDescription As String, _
ByVal bErrOrCancelled As Boolean)
If vsoApplication.CurrentScope = lngScopeID Then
Debug.Print "Exiting my scope " & nScopeID
Else
Debug.Print "Exit Scope " & bstrDescription & "(" & nScopeID & ")"
End If
End Sub