I'm using Project 2000 and want to loop through the tasks, printing out the contents of the "Project" field. Here's a code snippet: Sub LoopTasks() Dim Tsk As Task For Each Tsk In ActiveProject.Tasks If Not Tsk Is Nothing Then ' test for blank rows Debug.Print Tsk.Project End If Next Tsk End Sub This prints the name of the .mpp file, not the value of the task's "Project" field. What do I need to do to print the contents of the "Project" field? -- Carl
Figured out the problem. I inherited a project with a custom Text1 field named "Project". Changed the "Project" reference to "Text1" and I'm getting what I was looking for. -- Carl "Carl" wrote: > I'm using Project 2000 and want to loop through the tasks, printing out the > contents of the "Project" field. Here's a code snippet: > > Sub LoopTasks() > Dim Tsk As Task > For Each Tsk In ActiveProject.Tasks > If Not Tsk Is Nothing Then ' test for blank rows > Debug.Print Tsk.Project > End If > Next Tsk > End Sub > > This prints the name of the .mpp file, not the value of the task's "Project" > field. What do I need to do to print the contents of the "Project" field? > > -- Carl
If Not Tsk Is Nothing Then ' test for blank rows > Debug.Print Tsk.Project > End If How about if not Tsk.External then Debug.Print Activeproject.Name end if Finding the name of the project if it is a sub-project requires opening that project (using the path that you found in your code) and getting that project's name If you don't want to do that, then you can use some string functions to strip out everything before the / and everything from the . onward left(tsk.project,instr(tsk.project, ".")) or something like that will strip out the .mpp. You would do the same with the / which separates the path from the project name. -Jack Dahlgren "Carl" wrote in message news:CC965672-E9F2-41E4-B071-22CA83B40A9F@microsoft.com... > I'm using Project 2000 and want to loop through the tasks, printing out > the > contents of the "Project" field. Here's a code snippet: > > Sub LoopTasks() > Dim Tsk As Task > For Each Tsk In ActiveProject.Tasks > If Not Tsk Is Nothing Then ' test for blank rows > Debug.Print Tsk.Project > End If > Next Tsk > End Sub > > This prints the name of the .mpp file, not the value of the task's > "Project" > field. What do I need to do to print the contents of the "Project" field? > > -- Carl
Jack, Thanks for your response. Turns out this was pilot error on my part, I didn't realize that the column labeled "Project" was actually "Text1". Once I figured that out I was able to move on and bump my head on the next stumbling block. -- Carl "Jack Dahlgren MVP" wrote: > If Not Tsk Is Nothing Then ' test for blank rows > > Debug.Print Tsk.Project > > End If > > How about > if not Tsk.External then > Debug.Print Activeproject.Name > end if > > Finding the name of the project if it is a sub-project requires opening that > project (using the path that you found in your code) and getting that > project's name > > If you don't want to do that, then you can use some string functions to > strip out everything before the / and everything from the . onward > left(tsk.project,instr(tsk.project, ".")) or something like that will strip > out the .mpp. You would do the same with the / which separates the path from > the project name. > > -Jack Dahlgren > > "Carl" wrote in message > news:CC965672-E9F2-41E4-B071-22CA83B40A9F@microsoft.com... > > I'm using Project 2000 and want to loop through the tasks, printing out > > the > > contents of the "Project" field. Here's a code snippet: > > > > Sub LoopTasks() > > Dim Tsk As Task > > For Each Tsk In ActiveProject.Tasks > > If Not Tsk Is Nothing Then ' test for blank rows > > Debug.Print Tsk.Project > > End If > > Next Tsk > > End Sub > > > > This prints the name of the .mpp file, not the value of the task's > > "Project" > > field. What do I need to do to print the contents of the "Project" field? > > > > -- Carl >