title: VBA - Add task to MS project from Excel
body: <p>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.</p>
  
  <p>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:</p>
  
  <pre><code>'Collect data
  strValue = Worksheets("Display").Range("B" &amp; i)
  strStartDate = Worksheets("Display").Range("G" &amp; i)
  strEndDate = Worksheets("Display").Range("G" &amp; i)
  Strresource = Worksheets("Display").Range("C" &amp; i)
  DurTim = CDec(Worksheets("Display").Range("E" &amp; i))
  ActDurTim = CDec(Worksheets("Display").Range("F" &amp; 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" &amp; i) = "Y" Then
      newproj.Tasks(i - 6).Milestone = False
  End If
  newproj.Tasks(i - 6).Start = strStartDate
  newproj.Tasks(i - 6).Duration = DurTim &amp; " hours"
  newproj.Tasks(i - 6).ActualDuration = ActDurTim &amp; "hours"
  If i &lt;&gt; 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
  </code></pre>
  
  <p>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.</p>