Where I can find the task ID for a task in an external project?

G

Guest

Hello,

I am working on a VBA macro to be used with Microsoft Office Project
Professional 2003.

The macro is doing some automated task relinking based in part on the
information stored in the task predecessor field. For the most part everything
is working as it is supposed to.

I have to my dismay discovered that if there is a large enough number of
predecessors, Microsoft Project simply store the first 252 characters of the
list followed by three periods ”…” in the predecessor field.

To deal with this I am trying to find the information I need in the
TaskDependency collection. Dependencies on tasks that are part of the local
project are easy. The dependencies I need help figuring out are the
dependencies on tasks in other projects.

If for example am trying to construct a predecessor that would look l

For example if a truncated predecessor should look like:

C:\Bobs Test Project.MPP\4

If I find the dependency in my TaskDependency collection, it will point to a
task in my local project that Microsoft Project uses as a link to the external
project (they appear grayed out in the task list). I can find the name of the
external project (C:\Bobs Test Project.MPP) easily enough. What I can not seem
to find is the task id of the task in the external project (the number 4 at the
end of my example).

Can anyone PLEASE tell me where I can find the task ID for a task in an
external project?

It has to be in the local project somewhere!

Bob
 
J

John

Hello,

I am working on a VBA macro to be used with Microsoft Office Project
Professional 2003.

The macro is doing some automated task relinking based in part on the
information stored in the task predecessor field. For the most part
everything
is working as it is supposed to.

I have to my dismay discovered that if there is a large enough number of
predecessors, Microsoft Project simply store the first 252 characters of the
list followed by three periods ”…” in the predecessor field.

To deal with this I am trying to find the information I need in the
TaskDependency collection. Dependencies on tasks that are part of the local
project are easy. The dependencies I need help figuring out are the
dependencies on tasks in other projects.

If for example am trying to construct a predecessor that would look l

For example if a truncated predecessor should look like:

C:\Bobs Test Project.MPP\4

If I find the dependency in my TaskDependency collection, it will point to a
task in my local project that Microsoft Project uses as a link to the
external
project (they appear grayed out in the task list). I can find the name of
the
external project (C:\Bobs Test Project.MPP) easily enough. What I can not
seem
to find is the task id of the task in the external project (the number 4 at
the
end of my example).

Can anyone PLEASE tell me where I can find the task ID for a task in an
external project?

It has to be in the local project somewhere!

Bob

Bob,
Here is what I do in a macro I wrote some years back. The
TaskDependencies object does not give the ID of the external task in
it's home file so I look at the predecessor field itself. As you know,
when viewing the Predecessor field as a column, the string is truncated
at 255 characters. However, internally the Project database stores the
complete predecessor string. So if you decode the predecessor string of
the task object, you will be able to read each ID at the subproject
level. For example, for a simple master test file I used the following
code:
Sub Ext_Preds()
Dim t As Task
Dim str1 As String
For Each t In ActiveProject.Tasks
If Not t is Nothing Then
If t.ExternalTask = False Then
str1 = t.Predecessors
While InStr(1, str1, ",") <> 0
p1 = InStr(1, str1, ",")
Debug.Print Mid(str1, 1, p1 - 1)
[here's where you would strip off the external ID]
str1 = Mid(str1, p1 + 1)
Wend
Debug.Print str1
[strip off the last ID here]
End If
End If
Next t

Of course, if you have lead or lag, you will need to account for those
in the string and adjust the delimiter pointer (i.e. p1) accordingly.

Hope this helps.
John
Project MVP
 
G

Guest

Thank you John,

That is just what I needed.

I appreciate your timely response.

Bob
 
P

Phil Monckton

Bob, i am glad you were able to get help on this, can i ask what you were
doing that needed this solution, i ask, as i have resistance in my
organisation to using external links as they cause problems when the
predecessing projects slips and the succeeding pm does know about it .... I
have a suspicion that if i could run it outside of their control then i could
use it to manage what we call external dependencies and instead of logging
Give and gets in a spreadsheet...

regards

Phil
 

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