Application.SetField method (Project)

Sets the value of a local custom field or enterprise custom field for the selected tasks or resources.

Syntax

expression. SetField( _Field_, _Value_, _Create_ )

expression A variable that represents an Application object.

Parameters

Name Required/Optional Data type Description
Field Required String The name of the field to set.
Value Required String The value of the field.
Create Optional Boolean True if a new value is created; otherwise, False. The default value is True.

Return value

Boolean

Remarks

If the custom field uses a lookup table that does not allow additional items to be entered, the specified Value must match a predefined value in the lookup table.

If the value of the Field argument does not exist as a custom field name for the selected items, the SetField method results in run-time error 1101.

Example

The following example sets the value of an enterprise task text custom field to one of the valid values in the lookup table for the custom field. To use the example, create a lookup table in Project Web App that includes the value Value 3, and then create a task custom text field that uses that lookup table. Select a task in the active project and run the command in the Immediate window in the Visual Basic Editor.

Application.SetField Field:="TestEntTaskText", Value:="Value 3"

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.