Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Data from Enterpise MS Project Files from Excel

Status
Not open for further replies.

AccessHelp123

Programmer
Apr 27, 2005
91
US
Hi,

I am trying to use excel macros to access enterprise MS project and get 'TimePhasedData'. I am not sure how to connect to the enterprise project on the server using VBA. Below is the code I have to opne a .mpp file residing on my local computer.

Sub test()
Dim oMP As MSProject.Application, oPJ As MSProject.Project

Set oMP = CreateObject("MSProject.Application")

oMP.FileOpenEx "C:\Documents and Settings\ii36250\My Documents\project1.mpp"
Set oPJ = ActiveProject
With oPJ
.Parent.Visible = True
End With
oMP.Quit

Set oPJ = Nothing
Set oMP = Nothing
End Sub

Not sure what the path will be for enterprise. The server path looks something like this.
I am then trying to access the time phase data for each project using the code below.
Sub TimePhasedDataTest()

Dim tsv As TimeScaleValue
Dim tsvs As TimeScaleValues
Dim prj As msopr
'Timephased for Task with a UniqueID of 1
Set tsvs = ActiveProject.Tasks(1).TimeScaleData( _
StartDate:=ActiveProject.ProjectStart, _
EndDate:=ActiveProject.ProjectFinish, _
Type:=pjTaskTimescaledWork, _
TimeScaleUnit:=pjTimescaleDays, Count:=1)
For Each tsv In tsvs
Debug.Print "Start: " & Format(tsv.StartDate, _
"Long Date"), "Work: " & Val(tsv.Value) / 60 & "h"
Next tsv
Debug.Print 'Blank line
'Timephased for Resource "Res"
Set tsvs = ActiveProject.Resources("Res").TimeScaleData( _
StartDate:=ActiveProject.ProjectStart, _
EndDate:=ActiveProject.ProjectFinish, _
Type:=pjResourceTimescaledWork, _
TimeScaleUnit:=pjTimescaleDays, Count:=1)
For Each tsv In tsvs
Debug.Print "Start: " & Format(tsv.StartDate, _
"Long Date"), "Work: " & Val(tsv.Value) / 60 & "h"
Next tsv

End Sub

Thanks for any help you can provide on how to accomplish this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top