ID: Q137167
The information in this article applies to:
In Microsoft Project, when you run a macro to return the UniqueID property of a resource assignment (Assignments collection), an incorrect number may be returned.
This problem occurs if you use the Add method to return the unique ID for a resource assignment if the resource has been assigned to the task multiple times. For example, if you run the following macro
Sub Macro1()
Dim X as Object
' Add resource to task and set variable X equal to first
' resource assignment
Set X = Projects(1).Tasks(1).Assignments.Add(1,1)
' Display unique ID for first resource assignment
MsgBox X.UniqueID
' Add resource to task a second time and set
' variable X equal to second resource assignment
Set X = Projects(1).Tasks(1).Assignments.Add(1,1)
' Display unique ID for second resource assignment
MsgBox X.UniqueID
End Sub
the second dialog box that should return the unique ID of the second
resource assignment (2) displays the value 1 instead.
The Add method returns the first assignment for the task when you assign a resource multiple times.
To work around this problem, use the specific Assignments object to return the UniqueID property as in the following example:
' Assignments(2) is the second resource assignment
' for the first task
MsgBox Projects(1).Tasks(1).Assignments(2).UniqueID
Microsoft provides examples of Visual Basic procedures for illustration
only, without warranty either expressed or implied, including but not
limited to the implied warranties of merchantability and/or fitness for a
particular purpose. This Visual Basic procedure is provided 'as is' and
Microsoft does not guarantee that it can be used in all situations.
Microsoft does not support modifications of this procedure to suit customer
requirements for a particular purpose.
Microsoft has confirmed this to be a problem in the Microsoft products listed at the beginning of this article. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.
For more information about the "Add Method," choose the Search button in the Visual Basic Reference and type
add
choose the Show Topics button, select the topic, and choose Go To.
Additional query words: 4.00 ole automation
Keywords : kbcode kbprg
Version : 4.0 4.1
Platform : MACINTOSH WINDOWS
Issue type : kbprb
Last Reviewed: November 25, 1997