I have text data in Text field 1,2,3 & 4 on the MSProject (Online Desktop Client MSO V2302) I would like for this data to appear in Text field 1,2,3 & 4 on the Resource Usage View.
I have VBA code to do this, but keep getting an error message: Object variable or with block variable not set (error 91).
(Sorry I am not a VBA programmer).
Can someone tell me what I have wrong?
Public Sub copy_task_location_to_resource_location()
Dim r As Integer
Dim a As Integer
Dim t As Integer
For r = 1 To ActiveProject.Resources.Count
'iterate through resources
ActiveProject.Resources(r).Text1 = ""
ActiveProject.Resources(r).Text2 = ""
ActiveProject.Resources(r).Text3 = ""
ActiveProject.Resources(r).Text4 = ""
For a = 1 To ActiveProject.Resources(r).Assignments.Count
'iterate through assignments
'match up with correct task
For t = 1 To ActiveProject.Tasks.Count
If Not ActiveProject.Resources(r).Assignments(a).Task Is Nothing Then
If ActiveProject.Tasks(t) = ActiveProject.Resources(r).Assignments(a).Task Then
'copy fields over
ActiveProject.Resources(r).Assignments(a).Text1 = ActiveProject.Tasks(t).Text1
ActiveProject.Resources(r).Assignments(a).Text2 = ActiveProject.Tasks(t).Text2
ActiveProject.Resources(r).Assignments(a).Text3 = ActiveProject.Tasks(t).Text3
ActiveProject.Resources(r).Assignments(a).Text4 = ActiveProject.Tasks(t).Text4
Exit For
End If
End If
Next t
Next a
Next r
Exit Sub
End Sub