Identifying dependencies in Master Project

Y

Yoav

Hi, All
I have difficulties to identify by code dependencies (predecessors and
successors) of tasks in a Master Project where the dependent tasks are from
other projects.
For example: Task A from Project 1 is a predecessor to task B from project 2.
When I'm seeking by code the predecessors of task B, I find task A^ which is
an external task in project 2. I do not know how to connect between task A^
(external task) in project 2 to task A in project 1.
Does anyone have an idea?
 
A

Adam Behrle

Yoav,

In VBA, the Predecessors field on the task should so a comma separated
list of predecessor tasks. External tasks are in the form of {mpp file
path}\TaskID.

So for example in project 2 that you mention, task B's predecessor
field should contain something like:
<>\project 1.published\1

If project 2 is open but not project 1, project 2 will contain place
holder tasks from project 1. In order to connect to the actual tasks
in project 1, you could open project 1 first:

Dim predProject As Project
FileOpen ""<>\project 1.published "" 'The path parsed from the
predecessor field

Set predProject = Projects(Projects.Count)

Dim predTask As Task
Set predTask = predProject.Tasks(1) 'The external task ID

''''''''''''

A different method might look like so:

If currentTask.PredecessorTasks(1).ExternalTask then
FileOpen currentTask.PredecessorTasks(1).Project
End if

Hope this helps,

Adam Behrle
QuantumPM
 
J

Jack Dahlgren

Yoav,

The method to open the external project is as Adam states, but parsing the
predecessors field is not a great practice. It truncates after a certain
number of characters, and if you have a number of external dependencies with
long paths it can easily chop off at an inconvenient place.
You can determine if a task is external by the ExternalTask property. Then
you can take the Project property of that task to open the file.

Sub extTasks()
Dim stask As Task
For Each Task In ActiveProject.Tasks
For Each stask In Task.SuccessorTasks
If stask.ExternalTask Then
MsgBox stask.Project
'replace with fileOpen stask.Project if you want to open the other project
End If
Next stask
Next Task
End Sub
 
J

John

Jack Dahlgren said:
Yoav,

The method to open the external project is as Adam states, but parsing the
predecessors field is not a great practice. It truncates after a certain
number of characters, and if you have a number of external dependencies with
long paths it can easily chop off at an inconvenient place.
You can determine if a task is external by the ExternalTask property. Then
you can take the Project property of that task to open the file.

Sub extTasks()
Dim stask As Task
For Each Task In ActiveProject.Tasks
For Each stask In Task.SuccessorTasks
If stask.ExternalTask Then
MsgBox stask.Project
'replace with fileOpen stask.Project if you want to open the other project
End If
Next stask
Next Task
End Sub

Jack,
I don't think your statement about parsing the predecessor or successor
string is correct. If the string is displayed or copied it will indeed
be truncated at 255 characters, but if parsed in VBA the whole string is
"available" since VBA pulls the entire string directly out of Project's
underlying database.

John
 

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