http://msdn.microsoft.com/en-us/library/aa188715(v=office.10) See also http://msdn.microsoft.com/en-us/library/aa155675(v=office.10) Example http://msdn.microsoft.com/en-us/library/aa164022(v=office.10) Applies to
Reverses the most recent undo unit, if the undo unit can be reversed.
Required. An expression that returns an Application object.
Use the Undo method to reverse actions one undo unit at a time.
The number of times that code can call the Undo method depends on whether or not the code is executing in the scope of an open undo unit. Code runs in the scope of an open undo unit if it is:
- A macro or add-on invoked by the Visio user interface.
- In an event handler responding to a Visio event other than the VisioIsIdle event.
- In a user-created undo scope.
If code is not executing in the scope of an open undo unit, it can call the Undo method for each undo unit presently on the Visio undo stack. The maximum number of units on the undo stack is set in the Options dialog box on the General tab (20 is the default). If the number of calls to the Undo method exceeds the number of undo units on the stack, no action is taken and the Undo method raises no exception.
If code is executing in the scope of an open undo unit, it can call the Undo method once for each operation in the open undo unit. If there are additional calls to the Undo method, it will raise an exception and take no action. For example, if code in a macro performs two operations, it can call the Undo method twice. If the macro calls the Undo method a third time, the Undo method will raise an exception.
Code that calls the Undo method from within the scope of an undo unit cannot call the Redo method to reverse the action. The Redo method can only be called when there are no open undo units.
The Undo method also raises an exception if the Visio instance is presently performing an undo or redo. To determine whether the Visio instance is undoing or redoing, use the IsUndoingOrRedoing property.
You can call the Undo method from the VisioIsIdle event handler because the VisioIsIdle event can only fire when the IsUndoingOrRedoing property is False. You can also call the Undo method from code not invoked by the Visio instance, for example, code invoked from the Visual Basic Editor or from an external program.
You can undo most actions, but not all. Use the Redo method to reverse the effect of the Undo method.