LinkTasksEdit Method

Edits task dependencies (links).

Syntax

expression**.LinkTasksEdit(From, To, Delete, Type, Lag, PredecessorProjectName, SuccessorProjectName)**

*expression   *     Optional. An expression that returns an Application object.

From    Required Long. The identification number of a predecessor task.

To    Required Long. The identification number of a successor task.

Delete    Optional Boolean. True if Microsoft Office Project 2003 deletes the referenced link. The default value is False.

Type    Optional Long. The relationship between tasks that become linked. Can be one of the following PjTaskLinkType constants: pjFinishToFinish, pjFinishToStart, pjStartToFinish, or pjStartToStart. 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.

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

Applies to | Application Object

See Also | LinkTasks Method | UnlinkTasks Method