I'm trying to programmatically insert actual data into the Microsoft Project timescaled data. The data in dsExportData looks like this:
UProj_ID BD_TASK_ID ActualCost_AccountingDate Total
216 1 00:00.0 0
216 1 00:00.0 500
216 1 00:00.0 2000
216 1 00:00.0 900
216 1 00:00.0 -80
216 1 00:00.0 800
216 1 00:00.0 80000
216 1 00:00.0 90
216 1 00:00.0 17
216 1 00:00.0 50
216 1 00:00.0 240
My code to export the data is as follows:
Dim objAssignment As Assignment intGridRow = 0 appProj.OptionsCalculation(AutoCalcCosts:=False) Dim tsvs As TimeScaleValues Do Until intGridRow = gridExportOptions.RowCount If gridExportOptions.GetRowCellValue(intGridRow, gridExportOptions.Columns(2)) = True Then objAssignment = Nothing intTASK_ID = ReturnTaskID(gridExportOptions.GetRowCellValue(intGridRow, gridExportOptions.Columns(0))) If intTASK_ID <> 0 Then objAssignment = appProj.Application.ActiveProject.Tasks(intTASK_ID).Assignments.Add(ResourceID:=appProj.ActiveProject.Resources(strRES_ID).ID) intCounter = 0 Do Until intCounter = dsExportDetail.Tables(0).Rows.Count 'Loop through and insert TimeScaledData If dsExportDetail.Tables(0).Rows(intCounter).Item("BD_TASK_ID") = gridExportOptions.GetRowCellValue(intGridRow, gridExportOptions.Columns("MSPTask_UID")) Then If CDec(dsExportDetail.Tables(0).Rows(intCounter).Item("Total")) > 60000000 Then boolWarning = True Else If dsExportDetail.Tables(0).Rows(intCounter).Item(2) Is DBNull.Value Then dateAssign = Now() 'If there is no date, assign data to the current day tsvs = objAssignment.TimeScaleData(dateAssign, dateAssign, 28, 4) tsvs.Add(dsExportDetail.Tables(0).Rows(intCounter).Item("Total"), 1) Else dateAssign = dsExportDetail.Tables(0).Rows(intCounter).Item(2) tsvs = objAssignment.TimeScaleData(dateAssign, dateAssign, 28, 4) ' tsvs.Add(dsExportDetail.Tables(0).Rows(intCounter).Item("Total"), 1) 'For Each tsv In tsvs tsvs(1).Value = dsExportDetail.Tables(0).Rows(intCounter).Item("Total") ' Next 'Add TSV data End If End If Else End If intCounter += 1 Loop End If End If intGridRow += 1 Loop
This code has a couple of issues:
1) The Cost total for the task is accurate. However, the timephased data is still blank.
2) The last record for the first task throws an error: "The argument value is not valid." I don't understand why this is occurring - the date is valid ('6/16/2011'), and the amount is $240.00.
Any ideas on what I'm missing?
Thanks!