I'm trying to write some VBScript to time how long it takes to perform certain operations within Microsoft Project over wide-area networks. In order to do this, I need a progammatic way to login to the Microsoft Project server, as simply doing the CreateObject call does not automatically do the login to that I'd get if I simply launched Project with a double-click.
After some Googling, I found some code that almost gets me what I want. For instance, this sample allows me to time how long it takes to open a project:
-----
Function PerformMsProjectOpen(ProjectName)
Const pjDoNotSave = 0
Dim Results(0) ' Time taken to open the project
Dim TimeBefore ' Timestamp before opening
Dim TimeAfter ' Timestamp after opening
Dim projApp ' Object for the MS Project application
Dim WshShell ' Shell for running MS Project
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "D:\PROGRA~1\MICROS~2\OFFICE11\WINPROJ.EXE", 2, False
WScript.Sleep(10000)
Set projApp = CreateObject("MsProject.Application")
projApp.Visible = True
TimeBefore = Timer()
projApp.FileOpen (ProjectName)
TimeAfter = Timer()
projApp.Quit(pjDoNotSave)
Results(0) = DiffTimes (TimeAfter, TimeBefore)
PerformMsProjectOpen = Results
End Function
-----
The one thing I can't do with the above that I wish I could is time how long it's taking to connect to the Project Server, which would mean not just using a shell to launch the app and then connecting to it after waiting 10 seconds like I am (I wait 10 seconds because it may take anywhere from, say, 2 seconds to 6 seconds, depending on the WAN). Before I went with the above, I spent a lot of time trawling the Microsoft Project object model to figure out if there was some "Connect" or "Login" type of method for the Application object, but it seems there isn't. There doesn't even seem to be a way to connect to a Project Server from within the app without quitting and restarting, so I wasn't able to get it to reveal the secret by doing a Record Macro. I am getting the sense it's just not possible. Can anyone prove me wrong?
Thanks!
After some Googling, I found some code that almost gets me what I want. For instance, this sample allows me to time how long it takes to open a project:
-----
Function PerformMsProjectOpen(ProjectName)
Const pjDoNotSave = 0
Dim Results(0) ' Time taken to open the project
Dim TimeBefore ' Timestamp before opening
Dim TimeAfter ' Timestamp after opening
Dim projApp ' Object for the MS Project application
Dim WshShell ' Shell for running MS Project
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "D:\PROGRA~1\MICROS~2\OFFICE11\WINPROJ.EXE", 2, False
WScript.Sleep(10000)
Set projApp = CreateObject("MsProject.Application")
projApp.Visible = True
TimeBefore = Timer()
projApp.FileOpen (ProjectName)
TimeAfter = Timer()
projApp.Quit(pjDoNotSave)
Results(0) = DiffTimes (TimeAfter, TimeBefore)
PerformMsProjectOpen = Results
End Function
-----
The one thing I can't do with the above that I wish I could is time how long it's taking to connect to the Project Server, which would mean not just using a shell to launch the app and then connecting to it after waiting 10 seconds like I am (I wait 10 seconds because it may take anywhere from, say, 2 seconds to 6 seconds, depending on the WAN). Before I went with the above, I spent a lot of time trawling the Microsoft Project object model to figure out if there was some "Connect" or "Login" type of method for the Application object, but it seems there isn't. There doesn't even seem to be a way to connect to a Project Server from within the app without quitting and restarting, so I wasn't able to get it to reveal the secret by doing a Record Macro. I am getting the sense it's just not possible. Can anyone prove me wrong?
Thanks!