New to VBA, I am successfully importing and reading a Task List and Resources from Excel, executing VBA in Excel and inserting these records into MS Project. I am looking at setting the ActiveProject.Resources.Standardrate = "100p/h"
, however I am getting an error.
The code being applied (credit to previous answers provided to other related questions on Stackoverflow for the following code).
If Not ExistsInCollection (newproject.Resources, strResource) Then
newproject.resources.add.name = StrResource <-- This works, resources are added.
' However, inserting the following line:
newproject.resources.standardrate = "100p/h" <-- It errors here
End if
Any assistance is greatly appreciated - Thank you.
CodePudding user response:
The code needs a minor modification to get a reference to the newly-added resource so that it can then be updated:
If Not ExistsInCollection (newproject.Resources, strResource) Then
Dim r as Resource
Set r = newproject.Resources.Add (StrResource)
r.StandardRate = 100
End if