Dear Gurus,
Apologies first, I'm inexperienced with Project VBA, however from the internet I've managed to get some small code segments working.
I've been struggling with someting that I accept MS Project was not designed to do, basically feed the start and finish dates from my own calculated dates. Reasons are fairly obscure, but I do have such a bizzare need.
Within my macro loop I've got to this point:
Dim i As Long
Dim TempCal As Variant
For i = 1 To ActiveProject.Tasks.Count Step 1
If Not ActiveProject.Tasks(i) Is Nothing Then
If ActiveProject.Tasks(i).GetField(FieldNameToFieldConstant("Start MBJ1")) > 0 Then
ActiveProject.Tasks(i).SetField pjTaskDuration, "0?"
TempCal = ActiveProject.Tasks(i).GetField(FieldNameToFieldConstant("Start1"))
ActiveProject.Tasks(i).SetField pjTaskStart, TempCal
TempCal = ActiveProject.Tasks(i).GetField(FieldNameToFieldConstant("Finish1"))
ActiveProject.Tasks(i).SetField pjTaskFinish, TempCal
End If
End If
Next i
Macro appears to compile OK, and runs fine. I stepped through it and it selects the corect lines of the project and correctly sets the pjTaskDuration
With the pjTaskStart and pjTaskFinish, I'm getting nothing but random results. I checked the values of TempCal prior to attempting to SetField, and in both cases the values contained were the correct dates I wished.
Can anybody guide me to my mistake?
Many thanks for your time.