I have a simple MS Project file (2007) with just couple of tasks.
I have also created a custom field called VBATest
and assigned values to this custom field against the two project tasks.
I would like to retrieve a list of project tasks and the value assigned to the custom field like this;
ProjectTask | VBATest <--Custom field
------------|--------
Task1 | vba1
Task2 | vba2
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
Here is what I have done so far.
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 & "," & ass.VBATestField '<<PROBLEM Line
Next ass
Debug.Print Project_Task.Name & "~" & assignCFVal
assignCFVal = ""
End If
Next Project_Task
pjApp.FileClose pjDoNotSave
pjApp.Quit
Set pjApp = Nothing
End Sub