如何使用 Name 属性 select 资源,然后 return 另一个属性值
How to select a Resource by using the Name attribute and then return another attribute value
在 MS Project 中,我想编写 VBA 代码,使用 Resource.Name 属性在资源 sheet 中定位资源,然后可以 return 一个值资源。例如,我想说找到名为 'John' 的资源,然后能够 return 他的 'Initials'、'Std.Rate' 等
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
Assignment object has a property (Resource) that returns the associated Resource 对象使这成为一项微不足道的任务:
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
在 MS Project 中,我想编写 VBA 代码,使用 Resource.Name 属性在资源 sheet 中定位资源,然后可以 return 一个值资源。例如,我想说找到名为 'John' 的资源,然后能够 return 他的 'Initials'、'Std.Rate' 等
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
Assignment object has a property (Resource) that returns the associated Resource 对象使这成为一项微不足道的任务:
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