Reputation: 3
I am trying to change the resource hours time phasing in the Resource Usage view by VB.NET/VSTO code.
I have really basic code like this:
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Globals.ThisAddIn.Application.ActiveProject.Resources.UniqueID(1).TimeScaleData(StartDate:="13/03/18 00:00", EndDate:="14/03/18 00:00").Item(1).Value = "1"
End Sub
When I try to run the code to test, I receive the following error message. Does anyone know how I can change this view programmatically, please?
Error: System.Runtime.InteropServices.COMException: 'The argument value is not valid.'
Upvotes: 0
Views: 99
Reputation: 8442
To change resource work, change the value at the assignment level.
The TimeScaleData.Value property is read-only when aggregated to the Task or Resource level. To visualize this, look at the Resource Usage view. You can see the total work at the resource level but can't change the values. You can only change the values on the assignments shown below.
Loop through all of the assignments for that resource and adjust the values as needed. Keep in mind that the TimeScaleData method uses weeks (not days) as the default TimeScaleUnit.
Note: Work values are in minutes.
Upvotes: 0