AccessHelp123
Programmer
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.
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.