PDA

View Full Version : Resetting Task.Start date to 8:00 AM



KeithRoberts
01-07-2009, 08:54 AM
I have a project plan where the time on the start dates are wrong. For example, I may have 12/19/2008 16:00:00 or 12/18/2008 15:00:00. I have been working with VBA code to reset the time to 12/18/2008 8:00:00 or 12/19/2008 8:00:00. What is occuring is that I am getting durations that are fractional, for example. 8.25. or 8.12.

There are too many to manually correct, so I searched the internet and found code to reset the durations. However, it is not working on all dates.

The code I am using as as follows:



Set tsks = ActiveProject.Tasks

For Each tsk In tsks
If Not tsk Is Nothing Then
If Not tsk.Summary Then
sTaskID = tsk.ID
dtStart = CDate(Format((tsk.Start), "mm/dd/yyyy")) + 0.333333333333333
dtFinish = CDate(Format((tsk.Finish), "mm/dd/yyyy")) + 0.708333333333333
tsk.Start = dtStart
tsk.Finish = dtFinish
dblDuration = Application.DateDifference(tsk.Start, tsk.Finish, Standard)
dMod = dblDuration Mod 480
If dMod <> 0 Then
dblDuration = dblDuration + (480 - dMod)
End If
tsk.Duration = dblDuration
End If
End If
Next tsk

Application.CalculateProject



The Finish date is being reset to 5:00 PM, but the Start remains the same. I have tried to reset the duration, but this does not work.

What have I missed or what am I doing wrong?