vba - Reading and writing MS Project TimeScaleData for Resources, and Assignments -
i pulling projected cost excel reports , external db. part of monthly projections update project overheads. need accurately pull monthly cost write monthly cost overheads tasks.
i having trouble understanding why read , write assignment instead of directly cost resource?
read month cost resource (simplified):
dim tsvs timescalevalues dim res resource until budgetdate > activeproject.projectfinish each res in activeproject.resources set tsvs = res.timescaledata(startdate:=budgetdate, enddate:=budgetdate, type:=pjresourcetimescaledcost, timescaleunit:=pjtimescalemonths, count:=1) mymonthcost = val(tsvs(1).value) next res budgetdate = dateadd("m", budgetdate, 1) loop
there 1 timescalevalue in tsvs (the single month) believe i'm fine referencing tsvs(1).value instead of having increment through collection.
read month cost assignments:
do until budgetdate > laborfinishdate each res in activeproject.resources set asgts = res.assignments each asgt in asgts set tsvs = asgt.timescaledata(startdate:=budgetdate, enddate:=budgetdate, type:=pjassignmenttimescaledcost, timescaleunit:=pjtimescalemonths, count:=1) mymonthcost = mymonthcost + val(tsvs(1).value) next asgt next res budgetdate = dateadd("m", budgetdate, 1) loop
and write month overhead cost overhead task:
myoverhead = mymonthcost * myrate set tsk = activeproject.tasks("overhead") set tsvs = tsk.assignments(1).timescaledata(startdate:=budgetdate, enddate:=budgetdate, type:=pjassignmenttimescaledcost, timescaleunit:=pjtimescalemonths) tsvs(1).value = myoverhead
this method works me frustrated cannot work writing directly resource cost. don't understand why have read or write assignment (either task or resource) instead of directly resource itself. explain why 1 should read , write costs using assignments or if there better way using resources directly?
thanks time.
the answer assignments table contains timescaledata relates resource task (and vice versa), must write assignment related resource (or task). resource timescaledata related assignment timescaledata of resource.
Comments
Post a Comment