Table of contents
Collapse the table of content
Expand the table of content

Application.SetTaskField Method (Project)

office 365 dev account|Last Updated: 6/12/2017
1 Contributor

Sets the value of a task field specified by the name of the field.


expression. SetTaskField( ** Field, ** Value, ** AllSelectedTasks, ** Create, ** TaskID, ** ProjectName )

expression A variable that represents an Application object.


NameRequired/OptionalData TypeDescription
FieldRequiredStringThe name of the task field to set.
ValueRequiredStringThe value of the task field.
AllSelectedTasksOptionalBooleanTrue if the value of the field is set for all selected tasks. False if the value is set for the active task. The default value is False.
CreateOptionalBooleanTrue if Project creates a task when the active cell is on an empty row. The default value is True.
TaskIDOptionalLongThe identification number of the task containing the field to set. If AllSelectedTasks is True, TaskID is ignored.
ProjectNameOptionalStringIf the active project is a consolidated project, specifies the name of the project for the task specified by TaskID. If TaskID is not specified, ProjectName is ignored. The default value is the name of the active project.

Return Value



To set a task field by ID, use the SetTaskFieldByID method.


The following example changes the task field "Name" of Task ID 3 to "New Task Name", and then changes it back to the original name.

Sub Set_TaskField() 
    Dim T As Task 
    Set T = ActiveProject.Tasks(3)

    ' Save the task name 
    OldName = T.GetField(pjTaskName) 

    ViewApply Name:="&;Gantt Chart" 
    SetTaskField Field:="Name", Value:="New Task's Name", TaskID:=3 
    SetTaskField Field:="Name", Value:=OldName, TaskID:=3 
End Sub
© 2018 Microsoft