Sub WriteTimePhasedValue()
Dim TimeScaledvalues As TimeScaleValues
Dim TimeScaledValue As TimeScaleValue
Dim stdate, fsdate As Date
With ActiveProject.Tasks(5) ‘ i have taken static task ID, you might wanna change
stdate = Format(.Start, “Short date”)
fsdate = Format(.Finish, “Short date”)
Set TimeScaledvalues = .TimeScaleData(StartDate:=.Start, EndDate:=.Finish, Type:=pjTaskTimescaledActualWork, TimeScaleUnit:=pjTimescaleDays, Count:=1) ‘ You might wanna select task type to update
End With
For Each TimeScaledValue In TimeScaledvalues
If Val( TimeScaledValue .Value) <> 0 Then
MsgBox (ActiveProject.Tasks(5).Name & ” ” & stdate & ” ” & CStr( TimeScaledValue .Value / 60) & “h”)
TimeScaledValue .Value = 240 ‘in minutes
End If
Next TimeScaledValue
End Sub
Now at times you might get error 1100 : Check the server settings >> Operational policies >> Additional Server Settings >> Task Mode Settings >> “Automatically Scheduled”