Fully Qualified Task Name

F

Frank Steinkellner

Is it possible to extract a fully qualified task name into a single
line/record along with other fields such as:

Summary Task 1; Summary Task 2; Summary Task 3; Task Name; Resource; Start
Date
 
J

John

Is it possible to extract a fully qualified task name into a single
line/record along with other fields such as:

Summary Task 1; Summary Task 2; Summary Task 3; Task Name; Resource; Start
Date

Frank,
OK, help us out here. "Extract" can mean many different things. For
example, do you have a project file and you want to export data to some
other application? Are you trying to query the Project database
directly? Are you trying to save a project file as csv?

And what exactly is "a fully qualified task name"?

John
Project MVP
 
J

Jan De Messemaeker

Hi,

Such a name can be construed in VBA which can write it to wherever you want.
 
B

Brian Kennemer

Frank said:
Is it possible to extract a fully qualified task name into a single
line/record along with other fields such as:

Summary Task 1; Summary Task 2; Summary Task 3; Task Name; Resource;
Start Date

The article below gets you started on the VBA for this.
http://techrepublic.com.com/5100-6329_11-5030580.html

In your listing above it would provide you with
"Summary Task 3 | Task Name"

The Resource name and start date are pretty easy to add provided each
task only has one resource assigned. But the hard part will be getting
Summary Task 1 and 2 into it. for this you need a recursive function
that checks to see if the OutlineParent of a task also has an outline
parent and then runs again on that summary task to see if it also has
one, and so on and so on until it hits an outlineparent that does not
have a parent of its own. At that point you have 'hooks' into all the
summary tasks in the task's family tree and can construct your
concatenated string above.

So the good news is that I have given you some starting out code and a
description of what you need now. The bad news is that I dont have time
to wrtie it for you. :) If you post a request to the project developer
group and ask really nicely maybe someone will help you with the
recursive function.
 
J

Jan De Messemaeker

Hi,

Just an alternative approach to the "recursive" method - one that I find
more "natural":

thistask.text1=thistask.name
set runtask=thistask
For Ctr = 1 to thistask.outlinelevel-1
set runtask=runtask.outlineparent
set thistask.text1=runtask.name & "!" & thistask.text1
next ctr

HTH

--
Jan De Messemaeker, Microsoft Project Most Valuable Professional
http://users.online.be/prom-ade/
For FAQs: http://www.mvps.org/project/faqs.htm
Brian Kennemer said:
Frank said:
Is it possible to extract a fully qualified task name into a single
line/record along with other fields such as:

Summary Task 1; Summary Task 2; Summary Task 3; Task Name; Resource;
Start Date

The article below gets you started on the VBA for this.
http://techrepublic.com.com/5100-6329_11-5030580.html

In your listing above it would provide you with
"Summary Task 3 | Task Name"

The Resource name and start date are pretty easy to add provided each
task only has one resource assigned. But the hard part will be getting
Summary Task 1 and 2 into it. for this you need a recursive function
that checks to see if the OutlineParent of a task also has an outline
parent and then runs again on that summary task to see if it also has
one, and so on and so on until it hits an outlineparent that does not
have a parent of its own. At that point you have 'hooks' into all the
summary tasks in the task's family tree and can construct your
concatenated string above.

So the good news is that I have given you some starting out code and a
description of what you need now. The bad news is that I dont have time
to wrtie it for you. :) If you post a request to the project developer
group and ask really nicely maybe someone will help you with the
recursive function.

--

Brian Kennemer
microsoft consulting services
brian[period]kennemer[the "at" symbol]microsoft[period]com
 
B

Brian Kennemer

Jan said:
Hi,

Just an alternative approach to the "recursive" method - one that I
find more "natural":

thistask.text1=thistask.name
set runtask=thistask
For Ctr = 1 to thistask.outlinelevel-1
set runtask=runtask.outlineparent
set thistask.text1=runtask.name & "!" & thistask.text1
next ctr

HTH

Cool.

So for those keeping score at home Jan just kicked my ass. :)

The only problem was that you cannot use SET on a task property. ;-)

So the code to do exactly what the OP asked for is:

Sub foo()
Dim ThisTask As Task
Dim RunTask As Task
Dim ctr As Integer
For Each ThisTask In ActiveProject.Tasks
ThisTask.Text1 = ThisTask.Name
Set RunTask = ThisTask
For ctr = 1 To ThisTask.OutlineLevel - 1
Set RunTask = RunTask.OutlineParent
ThisTask.Text1 = RunTask.Name & " | " & _
ThisTask.Text1
Next ctr
If ThisTask.Summary = False Then
ThisTask.Text1 = ThisTask.Text1 & " | " & _
ThisTask.ResourceNames & " | " & ThisTask.Start
End If
Next ThisTask
End Sub

Newsgroups are very cool! :)
 
B

Brian Kennemer

Brian said:
Cool.

So for those keeping score at home Jan just kicked my ass. :)

The only problem was that you cannot use SET on a task property. ;-)

So the code to do exactly what the OP asked for is:

Sub foo()
Dim ThisTask As Task
Dim RunTask As Task
Dim ctr As Integer
For Each ThisTask In ActiveProject.Tasks
ThisTask.Text1 = ThisTask.Name
Set RunTask = ThisTask
For ctr = 1 To ThisTask.OutlineLevel - 1
Set RunTask = RunTask.OutlineParent
ThisTask.Text1 = RunTask.Name & " | " & _
ThisTask.Text1
Next ctr
If ThisTask.Summary = False Then
ThisTask.Text1 = ThisTask.Text1 & " | " & _
ThisTask.ResourceNames & " | " & ThisTask.Start
End If
Next ThisTask
End Sub

Newsgroups are very cool! :)

Actually, it should be this to include a trap for blank task lines:

Sub foo()
Dim ThisTask As Task
Dim RunTask As Task
Dim ctr As Integer
For Each ThisTask In ActiveProject.Tasks
If Not (ThisTask Is Nothing) Then
ThisTask.Text1 = ThisTask.Name
Set RunTask = ThisTask
For ctr = 1 To ThisTask.OutlineLevel - 1
Set RunTask = RunTask.OutlineParent
ThisTask.Text1 = RunTask.Name & " | " & _
ThisTask.Text1
Next ctr
If ThisTask.Summary = False Then
ThisTask.Text1 = ThisTask.Text1 & " | " & _
ThisTask.ResourceNames & " | " & ThisTask.Start
End If
End If
Next ThisTask
End Sub
 
B

Brian Kennemer

Brian Kennemer wrote:

Actually, it should be this to include a trap for blank task lines:

Sub foo()
Dim ThisTask As Task
Dim RunTask As Task
Dim ctr As Integer
For Each ThisTask In ActiveProject.Tasks
If Not (ThisTask Is Nothing) Then
ThisTask.Text1 = ThisTask.Name
Set RunTask = ThisTask
For ctr = 1 To ThisTask.OutlineLevel - 1
Set RunTask = RunTask.OutlineParent
ThisTask.Text1 = RunTask.Name & " | " & _
ThisTask.Text1
Next ctr
If ThisTask.Summary = False Then
ThisTask.Text1 = ThisTask.Text1 & " | " & _
ThisTask.ResourceNames & " | " & ThisTask.Start
End If
End If
Next ThisTask
End Sub

Oh and this might all be a moot point since you only get 256 characters
in a text field. :)
 

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