How Can I enumrates visible tasks by VBA?

Z

Zoo

I have a project which contains following tasks.
----------------
ID Task Name
----------------
1 Development
2 VBA
3 C++
4 Test
5 Unit Test
6 Combined Test

In Gantt chart , ID 1:Development is collapsed.

1 +Development
4 -Test
5 Unit Test
6 Combined Test

How Can I enumrates visible tasks (ID 1,4,5,6)?

Sub Test()
For i = 1 to ActiveProject.Tasks.Count
' If ????? then
Debug.Print ActiveProject.Tasks(i).Id , ActiveProject.Tasks(i).Name
' End If
Next
End Sub
 
R

Rod Gill

The only way I know is to select all tasks, then enumerate thru the selected
tasks collection:

Sub Sel()
Dim Tsk As Task
SelectAll
For Each Tsk In ActiveSelection.Tasks
If Not Tsk Is Nothing Then
Debug.Print Tsk.Name
End If
Next Tsk
End Sub


--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 
Z

Zoo

Thank you so much, Rod.

It works very well.


Rod Gill said:
The only way I know is to select all tasks, then enumerate thru the
selected tasks collection:

Sub Sel()
Dim Tsk As Task
SelectAll
For Each Tsk In ActiveSelection.Tasks
If Not Tsk Is Nothing Then
Debug.Print Tsk.Name
End If
Next Tsk
End Sub


--

Rod Gill
Project MVP

NEW!! Project VBA Book, for details visit: http://www.projectvbabook.com
 

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