Skip to content

Latest commit

 

History

History
95 lines (45 loc) · 1.43 KB

Project.Assignments.Count.md

File metadata and controls

95 lines (45 loc) · 1.43 KB
title ms.service api_name ms.assetid ms.date ms.localizationpriority
Assignments.Count property (Project)
project-server
Project.Assignments.Count
de8cee7b-a471-4c3f-2965-de6c3d47dda5
06/08/2017
medium

Assignments.Count property (Project)

Gets the number of items in the Assignments collection. Read-only Long.

Syntax

expression.Count

expression A variable that represents an 'Assignments' object.

Example

The following example prompts the user for the name of a resource and then assigns that resource to tasks without any resources.

Sub AssignResource() 

 

 Dim T As Task ' Task object used in For Each loop 

 Dim R As Resource ' Resource object used in For Each loop 

 Dim Rname As String ' Resource name 

 Dim RID As Long ' Resource ID 

 

 RID = 0 

 RName = InputBox$("Enter the name of a resource: ") 

 

 For Each R in ActiveProject.Resources 

 If R.Name = RName Then 

 RID = R.ID 

 Exit For 

 End If 

 Next R 

 

 If RID <> 0 Then 

 ' Assign the resource to tasks without any resources. 

 For Each T In ActiveProject.Tasks 

 If T.Assignments.Count = 0 Then 

 T.Assignments.Add ResourceID:=RID 

 End If 

 Next T 

 Else 

 MsgBox Prompt:=RName & " is not a resource in this project.", buttons:=vbExclamation 

 End If 

 

End Sub

See also

Assignments Collection Object

[!includeSupport and feedback]