Application.LinkTasksEdit method (Project)

Edits task dependencies (task links).

Syntax

expression. LinkTasksEdit( _From_, _To_, _Delete_, _Type_, _Lag_, _PredecessorProjectName_, _SuccessorProjectName_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
From Required Long Long. The identification number of a predecessor task.
To Required Long Long. The identification number of a successor task.
Delete Optional Boolean True if Project deletes the referenced link. The default value is False.
Type Optional Long The relationship between tasks that become linked. Can be one of the PjTaskLinkType constants. The default value is pjFinishToStart.
Lag Optional Variant The duration between linked tasks in default units. To specify lead time between tasks, use a negative value.
PredecessorProjectName Optional String The name of the subproject in a consolidated project that contains the task identified with From. If PredecessorProjectName is omitted, the current project is assumed.
SuccessorProjectName Optional String The name of the subproject in a consolidated project that contains the task identified with To. If SuccessorProjectName is omitted, the current project is assumed.

Return value

Boolean

Example

The following example prompts the user for a range of task identification numbers, and then links the tasks in the range from finish to start. This example assumes the ID range is valid, as well as the absence of any duplicate tasks, null tasks, consolidated projects, and so on.

Sub LinkFinishToStart() 
 
    Dim FirstID As String ' The ID number of the first task 
    Dim LastID As String ' The ID number of the last task 
    Dim NextID As Long ' The ID number of the next task to link 
 
    FirstID = InputBox$("Enter the ID number of the first task to link:") 
    If FirstID = Empty Then Exit Sub 

    LastID = InputBox$("Enter the ID number of the last task to link:") 
    If LastID = Empty Then Exit Sub 
 
    ' Convert FirstID from String to Long, then "seed" the loop. 
    NextID = CLng(FirstID) 
 
    Do Until NextID = CLng(LastID) 
        LinkTasksEdit From:=NextID, To:=NextID + 1, Type:=pjFinishToStart 
        NextID = NextID + 1 
    Loop 
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.