I want to populate actual work on a resource assignment.
Below is code written to just try the concept. It assigns 8 hours of actual work to each day defined for a resource assignment. The statement: "TSV.Value = 480" results in Error 1101 - 'Application-defined or object-defined error'
Sub TestTSV()
Dim ProjTasts As Tasks
Dim MyTask As Task
Dim TaskDate As Date, TaskTo As Date
Dim TaskAssignments As Assignments
Dim MyAssignment As Assignment
Dim Tsvs As TimeScaleValues
Dim TSV As TimeScaleValue
Set ProjTasks = ActiveProject.Tasks
' find the task
For Each projtask In ProjTasks
'these if statements step through all tasks in the project
TaskDate = projtask.Start
TaskTo = projtask.Finish
If Not (projtask Is Nothing) Then
If projtask.Summary = False Then
' find the assignment
Set TaskAssignments = projtask.Assignments
For Each MyAssignment In TaskAssignments
Set Tsvs = MyAssignment.TimeScaleData(TaskDate, TaskTo, Type:=pjResourceTimescaledActualWork, TimeScaleUnit:=pjTimescaleDays)
For Each TSV In Tsvs
Debug.Print TSV.StartDate, TSV.Value, TSV.EndDate, TSV.Parent, TSV.Index
TSV.Value = 480
Next TSV
Next MyAssignment
End If
End If
Next projtask
End Sub
Below is code written to just try the concept. It assigns 8 hours of actual work to each day defined for a resource assignment. The statement: "TSV.Value = 480" results in Error 1101 - 'Application-defined or object-defined error'
Sub TestTSV()
Dim ProjTasts As Tasks
Dim MyTask As Task
Dim TaskDate As Date, TaskTo As Date
Dim TaskAssignments As Assignments
Dim MyAssignment As Assignment
Dim Tsvs As TimeScaleValues
Dim TSV As TimeScaleValue
Set ProjTasks = ActiveProject.Tasks
' find the task
For Each projtask In ProjTasks
'these if statements step through all tasks in the project
TaskDate = projtask.Start
TaskTo = projtask.Finish
If Not (projtask Is Nothing) Then
If projtask.Summary = False Then
' find the assignment
Set TaskAssignments = projtask.Assignments
For Each MyAssignment In TaskAssignments
Set Tsvs = MyAssignment.TimeScaleData(TaskDate, TaskTo, Type:=pjResourceTimescaledActualWork, TimeScaleUnit:=pjTimescaleDays)
For Each TSV In Tsvs
Debug.Print TSV.StartDate, TSV.Value, TSV.EndDate, TSV.Parent, TSV.Index
TSV.Value = 480
Next TSV
Next MyAssignment
End If
End If
Next projtask
End Sub