dimanche 19 avril 2015

mistake in VBA timescaledata use for cost in Project

I have a little problem with small chunk of code. I want the code to show me monthly expenditures:

Dim TSV As TimeScaleValue
Dim TSVS As TimeScaleValues

Set TSVS = ActiveProject.Tasks(63).TimeScaleData( _
StartDate:=ActiveProject.ProjectStart, _
EndDate:=ActiveProject.ProjectFinish, _
Type:=pjTaskTimescaledCost, _
TimescaleUnit:=pjTimescaleMonths, Count:=1)
For Each TSV In TSVS
Debug.Print Val(TSV.Value)
Next TSV

Task(63) is actually a task that contains whole project and spans 22 months in this particular project. Yet the result in different projects are roughly the same: either one "0" or some cost that doesn't apply to the task. What's wrong with the code?

I wanted the program to give 22 values representing cost per month. I double-checked the task number, even referred to its name to be sure. Which leads to 2 other questions - is there a way to refer to a whole project instead of a task? And is the number (63 in this case) referring to unique Id? Sometimes program prompted me about "invalid argument" while clearly it wasn't.

Aucun commentaire:

Enregistrer un commentaire