共用方式為


Project) (List.Count 屬性

在 [ 清單 ] 集合中取得項的目數。 唯讀的 Long

語法

運算式計數

表達 代表 List 物件的變數。

範例

下面範例提示使用者輸入資源名稱,然後將資源分派給沒有任何資源的任務。

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

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應