ResourceAssignment Method
Assigns, removes, or replaces the resources of the selected tasks, or changes the number of units for a resource.
Syntax
expression.ResourceAssignment(Resources, Operation, With)
*expression * Optional. An expression that returns an Application object.
Resources Optional String. The names of the resources to be assigned, removed, or replaced in the selected tasks.
Note Project will not assign a resource if thousands separators or decimal separators are included in the unit values.
PjResAssignOperation
Constant |
---|
pjAssign |
pjRemove |
pjReplace |
pjChange |
With Optional String. When used with the pjReplace constant for Operation, specifies the names of the resources that replace the resources of the selected tasks.
Remarks
In Microsoft Office Project Professional 2003, you can use the Resources parameter to specify that a resource assignment is requested or demanded when using the Resource Substitution Wizard. For example, the following macro specifies that the assignment of r1 to the selected task is a requested assignment.
Sub RequestAssignment()
ResourceAssignment Resources:="r1[100%, R]", Operation:=pjChange, With:=""
End Sub
Note When using the Resources parameter in this way, D specifies "Demand," R specifies "Request," and N specifies "None." In addition, spaces are not allowed between the units value and the Request/Demand value. For example, Resources:="100%,R"
will work, but Resources:="100%, R"
will not.
In Microsoft Office Project Professional 2003, the Resource Substitution Wizard cannot substitute material resources. Therefore, you cannot request or demand a material resource for a particular assignment using the Resources parameter.
Example
The following example prompts the user for the name of a resource, and then assigns that resource to the selected tasks.
Sub AssignResourceToSelectedTasks()
Dim Entry As String ' The name of the resource to add to selected tasks
Dim R As Resource ' Resource object used in For Each...Next loop
Dim Found As Boolean ' Whether or not the resource is in the active project
Entry = InputBox$("Enter the name of the resource you want to add to the selected tasks.")
' Assume resource doesn't exist in the active project.
Found = False
' Look for the resource.
For Each R In ActiveProject.Resources
If Entry = R.Name Then Found = True
Next R
' If the resource is found, then assign it to selected tasks.
If Found Then
ResourceAssignment Resources:=Entry, Operation:=pjAssign
' Otherwise, tell user the resource doesn't exist.
Else
MsgBox ("There is no resource in the active project named " & Entry & ".")
End If
End Sub
Applies to | Application Object
See Also | Add Method | EnterpriseResSubstitutionWizard Method | Resources Property