How to programmatically identify FS, SS, FF links

M

meg99

Using 2003 & 2007,
Is there a way to programmatically identify the type of link
associated with a predecessor or successor- ie FS, SS, FF and the
associated lag (if any)?

meg99
 
R

Rod Gill

It's not so obvious, but TaskDependencies is the collection you need

activeproject.tasks(1).TaskDependencies(1).Type tells you the type which can
have one of 4 constant values:

pjFinishToFinish, pjFinishToStart, pjStartToFinish, or pjStartToStart.

Look at teh .To and .From properties to evaluate whether dependency is
predecessor or successor.
--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




meg99 said:
Using 2003 & 2007,
Is there a way to programmatically identify the type of link
associated with a predecessor or successor- ie FS, SS, FF and the
associated lag (if any)?

meg99

__________ Information from ESET Smart Security, version of virus
signature database 4966 (20100322) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4966 (20100322) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
M

meg99

Rod,
I can't seem to get this to work. Maybe I don't understand. Here is
some of the code I have in a user form:

I am counting the number of tasks that have a pred
If it does, I want to know what the link is (FS, SS, FF etc)

For Each jTask In ActiveSelection.Tasks
If jTask Is Nothing Then
Else
If jTask.Summary = False Then
If jTask.Predecessors = "" Then
tbNoPred = tbNoPred + 1
Else
MyLink = jTask.TaskDependencies(1)
End If


Note that MyLink shows empty although there is a link for the task

What should this be?

meg99
 
R

Rod Gill

Sub test()
Dim jTask As Task
Dim dep As TaskDependency
Dim tbNoPred As Long

For Each jTask In ActiveSelection.Tasks
If Not jTask Is Nothing Then
If jTask.Summary = False Then
For Each dep In jTask.TaskDependencies
tbNoPred = tbNoPred + 1
If dep.From.ID = jTask.ID Then
'Link is predecessor
MsgBox "Task: " & jTask.Name & " is a predecessor of" &
vbCrLf _
& dep.To.Name, vbOKOnly + vbInformation
Else
'Link is successor
MsgBox "Task: " & jTask.Name & " is a successor of" &
vbCrLf _
& dep.From.Name, vbOKOnly + vbInformation
End If
Next dep
End If
End If
Next jTask

End Sub


--

Rod Gill
Microsoft MVP for Project - http://www.project-systems.co.nz

Author of the only book on Project VBA, see: http://www.projectvbabook.com




meg99 said:
Rod,
I can't seem to get this to work. Maybe I don't understand. Here is
some of the code I have in a user form:

I am counting the number of tasks that have a pred
If it does, I want to know what the link is (FS, SS, FF etc)

For Each jTask In ActiveSelection.Tasks
If jTask Is Nothing Then
Else
If jTask.Summary = False Then
If jTask.Predecessors = "" Then
tbNoPred = tbNoPred + 1
Else
MyLink = jTask.TaskDependencies(1)
End If


Note that MyLink shows empty although there is a link for the task

What should this be?

meg99

__________ Information from ESET Smart Security, version of virus
signature database 4966 (20100322) __________

The message was checked by ESET Smart Security.

http://www.eset.com

__________ Information from ESET Smart Security, version of virus signature database 4966 (20100322) __________

The message was checked by ESET Smart Security.

http://www.eset.com
 
J

John

meg99 said:
Rod,
I can't seem to get this to work. Maybe I don't understand. Here is
some of the code I have in a user form:

I am counting the number of tasks that have a pred
If it does, I want to know what the link is (FS, SS, FF etc)

For Each jTask In ActiveSelection.Tasks
If jTask Is Nothing Then
Else
If jTask.Summary = False Then
If jTask.Predecessors = "" Then
tbNoPred = tbNoPred + 1
Else
MyLink = jTask.TaskDependencies(1)
End If


Note that MyLink shows empty although there is a link for the task

What should this be?

meg99

meg99,
Just a little clarification on the intent. I notice that your code loops
on currently selected tasks. Rod's more complete code does the same but
I'm not sure that is your intent.

If you only want to find the dependency data on a task or select group
of tasks then ActiveSelection.Tasks is the proper structure. It
presupposes the user has either manually selected a group of tasks or a
filter has been created to do so. However, if the real intent is to loop
through all tasks in the file then the correct syntax would be,
For Each jTask in ActiveProject.Tasks.

Another advantage of using the ActiveProject.Tasks structure is the code
runs in background mode which is faster than foreground processing that
occurs when using the ActiveSelection.Tasks structure.

Hope this helps.

John
Project MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top