Error message when macro assigns material resource to a task: "Run-Time Error 1101. The argument value is not valid"


In Microsoft Project, when you run a Microsoft Visual Basic for Applications macro that assigns a material resource, you may receive the following error message:

Run-time error '1101':

The argument value is not valid.


This behavior occurs when you run a Visual Basic for Applications macro that uses the Add method to assign a material resource and includes a variable material consumption rate in the Units value, for example, 2/d or 2/wk.

For example, the following macro generates the error described above:
Sub addRes()
ActiveProject.Tasks(1).Assignments.Add ResourceID:=1, Units:="2/d"
End Sub
This behavior occurs because the Units argument of the Add method accepts only an integer or decimal value. Other alphanumeric characters are invalid.

Note that if the macro is assigning a work resource rather than a material resource, a percent (%) sign included in the Units value generates the same error.


Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
To work around this problem, assign the material resource first; then modify the units for the assignment to add the variable material consumption rate.

For example, the following macro assigns a material resource and then changes its units to 2 per day:
Sub addRes()

'Add resource to task.
lAssignUID = ActiveProject.Tasks(1).Assignments.Add (ResourceID:=1)
'Based on assignment unique ID (UID) returned while adding
'resource, change units for resource.
ActiveProject.Tasks(1).Assignments.UniqueID(lAssignUID).Units = "2/d"

End Sub

Artikelnummer: 242723 – Letzte Überarbeitung: 22.03.2013 – Revision: 1