Application.LinkTasksEdit Method

Project Developer Reference

Edits task dependencies (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 Microsoft Office Project 2007 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.

Visual Basic for Applications
  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)
    <strong class="bterm">LinkTasksEdit</strong> From:=NextID, To:=NextID + 1, Type:=pjFinishToStart
    NextID = NextID + 1
Loop

End Sub

See Also