I've only done a little work pulling Project data into Excel. Here's a
snippet of code that might be useful. The routine takes as arguments a
folder path, a Project file name, and a Variant array to return data to the
calling routine. Uses OLEDB to query the Project file so that it doesn't
have to be open to grab data.
HTH,
Eric
Sub Get_Project_Data(My_Folder As String, Proj_File_Name As String,
numReturned As Long, retData() As Variant, _
success As Boolean)
Dim conData As New ADODB.Connection
Dim rstAssigns As New ADODB.Recordset
Dim intCount As Integer
Dim strSelect As String
Dim strResults As String
On Error GoTo MSProj_Pull_Failed
conData.ConnectionString =
"Provider=Microsoft.Project.OLEDB.11.0;PROJECT NAME=" & My_Folder &
Proj_File_Name
conData.ConnectionTimeout = 30
conData.Open
'
' Query for all tasks in the data which have the UniqueID that we are
looking for.
'
strSelect = "SELECT TaskUniqueID, TaskStart, TaskFinish, TaskName,
TaskEarlyStart, " & _
"TaskEarlyFinish, TaskLateStart, TaskLateFinish,
TaskPredecessors, " & _
"TaskSuccessors, TaskMilestone, TaskDuration,
TaskPercentComplete " & _
"FROM Tasks WHERE TaskUniqueID > 0 ORDER BY
TaskUniqueID "
rstAssigns.Open strSelect, conData
retData = rstAssigns.GetRows(5000) ' GetRows pulls as much data as
there is, or up to 5000 records...
numReturned = UBound(retData, 2) + 1 ' retData will be a zero-based
array
'
rstAssigns.Close
conData.Close
success = True
Exit Sub
'
MSProj_Pull_Failed:
success = False
'
End Sub