在 MS 项目中,我想编写 VBA 代码,该代码使用 Resource.Name 属性在资源工作表中定位资源,然后可以针对该资源返回一个值。 例如,我想说找到名为"John"的资源,然后能够返回他的"缩写","标准率"等。
For Each T In ActiveProject.Tasks
For Each asn In T.Assignments
If asn.ResourceName = "John" Then 'Find the User Resources
'Insert code here that finds John in the Resource sheet and returns his
'Std.Rate
End If
Next asn
Next T
赋值对象有一个属性(资源),该属性返回关联的资源对象,这使得这是一项简单的任务:
For Each T In ActiveProject.Tasks
For Each asn In T.Assignments
If asn.ResourceName = "John" Then 'Find the User Resources
' print resource's initials and standard rate
Debug.Print asn.Resource.Initials, asn.Resource.StandardRate
End If
Next asn
Next T