title: MS Project 2007 VBA to retrieve tasks and custom fields
body: <p>I have a simple MS Project file (2007) with just couple of tasks.
  I have also created a custom field called <code>VBATest</code> and assigned values to this custom field against the two project tasks.  </p>
  
  <p>I would like to retrieve a list of project tasks and the value assigned to the custom field like this;</p>
  
  <pre><code>ProjectTask | VBATest &lt;--Custom field
  ------------|--------
  Task1       | vba1
  Task2       | vba2
  </code></pre>
  
  <p>I'm doing this from Access 2007 VBA as this is where the final code will end up.
  I can get most of it working, but I can't seem to read the custom field value from the Assignments object.  Do you have Any ideas?
  Thanks</p>
  
  <p>Here is what I have done so far.</p>
  
  <pre><code>Sub LoadProjectFile()
  
  Dim pjApp As MSProject.Application
  Dim FileToOpen
  Dim Proj As MSProject.Project
  Dim Project_Task As Task
  Dim fd As FileDialog
  
  Set pjApp = New MSProject.Application
  
  If pjApp Is Nothing Then
  MsgBox "Project is not installed"
  End
  End If
  
  pjApp.Visible = True
  AppActivate "Microsoft Project"
  
  Set fd = Application.FileDialog(msoFileDialogFilePicker)
  fd.Filters.Clear
  fd.Filters.Add "Microsoft Project Files", "*.mpp"
  fd.AllowMultiSelect = False
  fd.Show
  If (fd.SelectedItems.Count = 0) Then
      'Application.GetOpenFilename("Microsoft Project Files (*.mpp), *.mpp")
      pjApp.Quit
      Set pjApp = Nothing
      Exit Sub
  End If
  
  pjApp.FileOpen fd.SelectedItems(1)
  Debug.Print "Project_Task_Name~CustomField"
  
  Dim ass As Assignment
  For Each Project_Task In pjApp.ActiveProject.Tasks
              If Not Project_Task Is Nothing Then
  
                  For Each ass In Project_Task.Assignments
                      assignCFVal = assignCFVal &amp; "," &amp; ass.VBATestField '&lt;&lt;PROBLEM Line
                  Next ass
  
                 Debug.Print Project_Task.Name &amp; "~" &amp; assignCFVal
                 assignCFVal = ""
              End If
          Next Project_Task
  
  pjApp.FileClose pjDoNotSave
  pjApp.Quit
  Set pjApp = Nothing
  
  End Sub
  </code></pre>