Share via


UnlinkSuccessors Method

Removes successors from a task.

Syntax

expression**.UnlinkSuccessors(Tasks)**

*expression   *     Required. An expression that returns a Task object.

Tasks Required Object. The successor Task or Tasks specified with Tasks are removed from the task specified with *expression   *.

Example

The following example removes the specified successor from every task in the active project.

Sub RemoveSuccessor()

    Dim Entry As String     ' Successor specified by user
    Dim SuccTask As Task    ' Successor task object
    Dim T As Task           ' Task object used in For Each loop
    Dim S As Task           ' Successor (task object) used in loop

    Entry = InputBox$("Enter the name of a successor to unlink from every task in this project.")
    Set SuccTask = Nothing
    
    ' Look for the name of the successor in tasks of the active project.
    For Each T In ActiveProject.Tasks
        If T.Name = Entry Then
            Set SuccTask = T
            Exit For
        End If
    Next T
    
    ' Remove the successor from every task in the active project.
    If Not (SuccTask Is Nothing) Then
        For Each T In ActiveProject.Tasks
            For Each S In T.SuccessorTasks
                If S.Name = Entry Then
                    T.UnlinkSuccessors SuccTask
                    Exit For
                End If
            Next S
        Next T
    End If
    
End Sub

Applies to | Task Object, Tasks Collection Object

See Also | LinkSuccessors Method | Successors Property | UnlinkPredecessors Method