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

Article translations Article translations
Article ID: 242723 - View products that this article applies to.
This article was previously published under Q242723
Expand all | Collapse all

Symptoms

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.

Cause

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.

Workaround

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
				

Properties

Article ID: 242723 - Last Review: March 22, 2013 - Revision: 6.0
Applies to
  • Microsoft Office Project Professional 2007
  • Microsoft Office Project Standard 2007
  • Microsoft Office Project Professional 2003
  • Microsoft Office Project Standard 2003
  • Microsoft Project Professional 2010
  • Microsoft Project Standard 2010
  • Microsoft Project 2013 Professional
  • Microsoft Project 2013 Standard
Keywords: 
kbbug kbpending KB242723

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com