title | ms.service | ms.assetid | ms.date | ms.localizationpriority |
---|---|---|---|---|
Tasks object (Project) |
project-server |
b7482b5a-7fac-531e-6793-610faca2f954 |
06/08/2017 |
medium |
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.
ActiveProject.Tasks.Add "Hang clocks"
Name |
---|
Add |
Name |
---|
Application |
Count |
Item |
Parent |
UniqueID |
[!includeSupport and feedback]