S
Steve Chermak
I am new at Project Server 2007.
We have an Excel macro that is designed to run overnight to launch Project
VBA code in order to update projects in the Project Server. These projects
were created in Project Web Access.
Right now the code is just prototype to try and get this working.
The VBA code will not properly check in the project, the project appears on
the force check in list in PWA afterwards.
We have gotten code going that will check in and out documents in a document
library, but we can not get this going and when we try and identify the error
codes they don't provide much help.
Below is the code. Test code put in indicates that the project can not be
checked out, let alone in, yet we don't know why. If anybody can help we
would appreciate it.
Thanks, Steve Chermak
========
Dim pjApp As Object, pjProj As MSProject.Project, pjApp2 As
MSProject.Application
Dim pjProjs As MSProject.Projects
Dim pjProjectName As String
Dim pjProjectFullName As String
Sub Execute_Open()
Application.WindowState = xlMinimized
If OpenProjectServer() = False Then
MsgBox "Error: Could NOT Open MSProject From Project Server!"
End
End If
Set pjApp2 = pjApp
pjApp2.FileOpenEx Name:="<>\VPMI SFU 2010 - MH CONSTRUCTION",
ReadOnly:=False
pjApp2.DisplayAlerts = False
pjApp2.WindowState = pjMaximized
Set pjProjs = pjApp2.Projects
Set pjProj = pjApp2.ActiveProject
MsgBox (pjProjs.Count)
MsgBox (pjProjs.Item(1).Name)
pjProjectFullName = pjProj.FullName
pjProjectName = pjProj.Name
Dim CanIt As Boolean
pjProjs.Item(1).Activate
CanIt = pjProjs.CanCheckOut(pjProjs.Item(1))
MsgBox (CanIt)
If pjProjs.CanCheckOut(pjProjs.Item(1)) Then
pjProjs.CheckOut (pjProjs.Item(1))
Else
MsgBox ("not checked out - error: " & Err.Number)
End If
pjProj.Tasks(2).Cost = 111
If pjProj.CanCheckIn = True Then
pjProj.CheckIn
Else
MsgBox ("not checked in " & Err.Number)
End If
pjApp2.FileCloseEx pjSave
pjApp.DisplayAlerts = True
pjApp2.WindowState = pjMinimized
Set pjProj = Nothing
Set pjApp2 = Nothing
Set pjWkbk = Nothing
Set pjApp = Nothing
Application.WindowState = xlNormal
End Sub
Function OpenProjectServer()
tStart = Timer
Set pjApp = Nothing
On Error Resume Next
Shell "C:\Program Files\Microsoft Office\Office12\WINPROJ.EXE /s
""http://vpmiweb1/PWA"""
Do While pjApp Is Nothing And Timer < (tStart + 30)
Set pjApp = GetObject(, "MSProject.Application")
Loop
If Not pjApp Is Nothing Then
OpenProjectServer = True
Else
OpenProjectServer = False
End If
End Function
We have an Excel macro that is designed to run overnight to launch Project
VBA code in order to update projects in the Project Server. These projects
were created in Project Web Access.
Right now the code is just prototype to try and get this working.
The VBA code will not properly check in the project, the project appears on
the force check in list in PWA afterwards.
We have gotten code going that will check in and out documents in a document
library, but we can not get this going and when we try and identify the error
codes they don't provide much help.
Below is the code. Test code put in indicates that the project can not be
checked out, let alone in, yet we don't know why. If anybody can help we
would appreciate it.
Thanks, Steve Chermak
========
Dim pjApp As Object, pjProj As MSProject.Project, pjApp2 As
MSProject.Application
Dim pjProjs As MSProject.Projects
Dim pjProjectName As String
Dim pjProjectFullName As String
Sub Execute_Open()
Application.WindowState = xlMinimized
If OpenProjectServer() = False Then
MsgBox "Error: Could NOT Open MSProject From Project Server!"
End
End If
Set pjApp2 = pjApp
pjApp2.FileOpenEx Name:="<>\VPMI SFU 2010 - MH CONSTRUCTION",
ReadOnly:=False
pjApp2.DisplayAlerts = False
pjApp2.WindowState = pjMaximized
Set pjProjs = pjApp2.Projects
Set pjProj = pjApp2.ActiveProject
MsgBox (pjProjs.Count)
MsgBox (pjProjs.Item(1).Name)
pjProjectFullName = pjProj.FullName
pjProjectName = pjProj.Name
Dim CanIt As Boolean
pjProjs.Item(1).Activate
CanIt = pjProjs.CanCheckOut(pjProjs.Item(1))
MsgBox (CanIt)
If pjProjs.CanCheckOut(pjProjs.Item(1)) Then
pjProjs.CheckOut (pjProjs.Item(1))
Else
MsgBox ("not checked out - error: " & Err.Number)
End If
pjProj.Tasks(2).Cost = 111
If pjProj.CanCheckIn = True Then
pjProj.CheckIn
Else
MsgBox ("not checked in " & Err.Number)
End If
pjApp2.FileCloseEx pjSave
pjApp.DisplayAlerts = True
pjApp2.WindowState = pjMinimized
Set pjProj = Nothing
Set pjApp2 = Nothing
Set pjWkbk = Nothing
Set pjApp = Nothing
Application.WindowState = xlNormal
End Sub
Function OpenProjectServer()
tStart = Timer
Set pjApp = Nothing
On Error Resume Next
Shell "C:\Program Files\Microsoft Office\Office12\WINPROJ.EXE /s
""http://vpmiweb1/PWA"""
Do While pjApp Is Nothing And Timer < (tStart + 30)
Set pjApp = GetObject(, "MSProject.Application")
Loop
If Not pjApp Is Nothing Then
OpenProjectServer = True
Else
OpenProjectServer = False
End If
End Function