I am currently opening a project in MS-Project from Excel sheet using VBA. I am also adding tasks, dates, duration and some more data.
My problem is that when I am adding a new task the default start time of the task is not as defined in the project (7:00 am) but 00:00. Here is the code i am using:
'Collect data
strValue = Worksheets("Display").Range("B" & i)
strStartDate = Worksheets("Display").Range("G" & i)
strEndDate = Worksheets("Display").Range("G" & i)
Strresource = Worksheets("Display").Range("C" & i)
DurTim = CDec(Worksheets("Display").Range("E" & i))
ActDurTim = CDec(Worksheets("Display").Range("F" & i))
'Define project defaults
newproj.DefaultStartTime = "7:00"
newproj.DefaultFinishTime = "16:00"
newproj.HoursPerDay = "7"
'Enter data to task
newproj.Tasks.Add (strValue)
'Check for milestone
If Worksheets("Display").Range("H" & i) = "Y" Then
newproj.Tasks(i - 6).Milestone = False
End If
newproj.Tasks(i - 6).Start = strStartDate
newproj.Tasks(i - 6).Duration = DurTim & " hours"
newproj.Tasks(i - 6).ActualDuration = ActDurTim & "hours"
If i <> 7 Then
newproj.Tasks(i - 6).Predecessors = newproj.Tasks(i - 6 - 1)
End If
If Not ExistsInCollection(newproj.Resources, Strresource) Then _
newproj.Resources.Add.Name = Strresource
newproj.Tasks(i - 6).ResourceNames = Strresource
I have tried to look in the Ms-Project objects of the tasks and the project itself for a solution but no luck. Any help would be grateful.