Tasks Object (Project)
Contains a collection of Task objects.
Using the Task Object
Use Tasks ( Index ), where Index is the task index number or task name, to return a single Task object. The following example prints the names of every resource assigned to every task in the active project.
Dim Temp As Long, A As Assignment Dim TaskName As String, Assigned As String, Results As String For Temp = 1 To ActiveProject.Tasks.Count TaskName = "Task: " & ActiveProject.Tasks(Temp).Name & vbCrLf For Each A In ActiveProject.Tasks(Temp).Assignments Assigned = A.ResourceName & ListSeparator & " " & Assigned Next A Results = Results & TaskName & "Resources: " & _ Left$(Assigned, Len(Assigned) - Len(ListSeparator & " ")) & vbCrLf & vbCrLf TaskName = "" Assigned = "" Next Temp MsgBox Results
Use the Tasks property to return a Tasks collection. The following example displays the name of every task in the selection.
Dim T As Task, Names As String For Each T In ActiveSelection.Tasks Names = Names & T.Name & vbCrLf Next T MsgBox Names
Use the Add method to add a Task object to the Tasks collection. The following example adds a new task to the end of the task list.