title: How to Add Column from MS Excel to MS Project - VBA
body: <p>I am writing a macro to add a column of data from an MS Excel sheet into an already existing MS Project document. When I run my macro the correct project is opened, but I get an error message saying that the project I opened has been deleted, even though it has not been deleted.</p>
  
  <p>Here is my current macro:</p>
  
  <pre><code>Sub newProjectColumn()
  Dim appProj As MSProject.Application
  Dim aProg As MSProject.Project
  Dim wb As Workbook
  Dim ws As Worksheet
  Dim rng As Range
  Set wb = ActiveWorkbook
  
  '~~&gt; Open MS Project
  Set ws = wb.Sheets("Sheet1")
  
  Set appProj = CreateObject("Msproject.Application")
  
  appProj.FileOpen "Project_1.mpp"
  
  Set aProg = appProj.ActiveProject
  
  appProj.Visible = True
  
  '~~&gt; Next, create new Column in project
  TableEditEx Name:="Project_1.mpp", TaskTable:=True, _
      NewFieldName:="Actual Duration", Title:="Actual Duration", Width:=12, _
      ShowInMenu:=True, _
      ColumnPosition:=29
  
  '~~&gt; Next, copy T:T from Excel.Then, paste to 29th column (i,29) in Project.
  Set Rng = ws.Range("T:T")
  ActiveSheet.Paste Destination:=Rng
  SelectTaskColumn Column:="Actual Duration"
  
  End Sub
  </code></pre>
  
  <p>Any help on what I have done wrong or if there is a better approach would be very much appreciated!</p>