Application.OpenUndoTransaction method (Project)

Create an undo transaction set for a series of operations.

Syntax

expression. OpenUndoTransaction( _Label_, _guid_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Label Required String Name that appears in the drop-down list for the Undo Transaction command.
guid Optional Variant GUID that uniquely identifies Label.

Remarks

The OpenUndoTransaction method is used in conjunction with CloseUndoTransaction method. Use OpenUndoTransaction and CloseUndoTransaction on a single command or on a group of commands.

You cannot nest one undo transaction within another.

Example

The following example demonstrates using the OpenUndoTransaction method to create an undo transaction set. After you run the macro, the task named Task outside transaction shows as the item Insert Task in the Undo drop-down list on the Quick Access Toolbar. The six tasks named UndoMe 1 to UndoMe 6 show as Create 6 tasks in the Undo list.

Sub CreateTasksWithUndoTransaction() 
    ActiveProject.Tasks.Add "Task outside transaction" 
    Application.OpenUndoTransaction "Create 6 tasks" 
    Dim i As Integer 
    For i = 1 To 6 
        ActiveProject.Tasks.Add "UndoMe " & i 
    Next 
    Application.CloseUndoTransaction  
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.