GetProjectServerVersion Method Example for Microsoft Project Server 2002This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.
The following sample checks to see whether the current project points to a valid Microsoft® Project Server. If Microsoft Project Server is not used for tracking or if there is no URL specified for tracking, Microsoft Project returns an error message. If the URL does not point to a valid Microsoft Project Server, Microsoft Project returns a trappable error (error code 1004). (This document is 4 printed pages)
If the current project points to a valid Microsoft Project Server, Microsoft Project returns an XML stream representing the following settings from Microsoft Project Server:
- AdminDefaultTrackingMethod. The default tracking method the administrator has set up on Microsoft Project Server: hours of work done per day or per week (1), percent of work complete (2), or actual work done and work remaining (3).
- AdminTrackingLocked. A Boolean value indicating whether the administrator has locked down the tracking method on Microsoft Project Server. A False value (0) allows project managers to change the default method for reporting progress if a different method is appropriate for a specific project, and a True value (1) forces project managers to use the progress reporting method specified by the administrator for all projects.
- ProjectIDInProjectServer. The project ID in the Microsoft Project Server database for the current project.
- ProjectManagerHasTransactions. The number of pending transactions the project manager has in Microsoft Project Web Access.
- ProjectManagerHasTransactionsForCurrentProject. The number of pending transactions for the current project the project manager has in Microsoft Project Web Access.
- TimePeriodGranularity. The defaults the administrator has set up for the intervals displayed in the Microsoft Project Web Access time sheet: resources should report their total hours worked during the entire time period that the administrator has set up as the default (0), resources should report their hours worked every day (1), or resources should report their total hours worked for a week (2).
- GroupsForCurrentProjectManager. The Microsoft Project Server security groups that the user belongs to. The XML is returned in the following format:
<ProjectServerSettingsReturn> <GroupsForCurrentProjectManager> <ProjectServerGroup>Name of first group that user belongs to </ProjectServerGroup> <ProjectServerGroup>Name of nth group that user belongs to </ProjectServerGroup> </GroupsForCurrentProjectManager> </ProjectServerSettingsReturn>
- Microsoft Project Standard 2002 or Microsoft Project Professional 2002, in addition to Microsoft Project Server
This code example assumes that you are familiar with Microsoft Project and Microsoft Visual Basic® for Applications (VBA), and that you can write or reuse supplementary code as necessary.
To run this code example, you must have Microsoft Project 2002 (Standard, Server, or Professional edition) installed on your computer. You can either paste the code into the Microsoft Visual Basic Editor (VBE) in Microsoft Project or into your VBA project.
You can copy and paste the Microsoft VBA code below.
Note If the ServerURL property does not point to a valid and functioning Microsoft Project Server, the GetProjectServerVersion method returns a trappable error (error code 1004).
Important In order to use the MakeServerURLTrusted method or the GetProjectServerVersion method, you must specify a Microsoft Project Server URL that begins with http:// in Collaboration Options (Collaborate menu).
To create a new macro
- On the Tools menu, point to Macro and click Macros.
- Type a name for your new macro in the Macro name box.
- Select the project where you wish to create the macro in the Macros in box.
- Click Create.
Sub mpsVersion() URL = ActiveProject.ServerURL If Application.GetProjectServerVersion(URL) = pjServerVersionInfo_P10 Then ActiveProject.MakeServerURLTrusted xmlStream = Application.GetProjectServerSettings( _ RequestXML:="<ProjectServerSettingsRequest>" _ & "<AdminDefaultTrackingMethod /><AdminTrackingLocked />" _ & "<ProjectIDInProjectServer />" _ & "<ProjectManagerHasTransactions />" _ & "<ProjectManagerHasTransactionsForCurrentProject />" _ & "<TimePeriodGranularity /><GroupsForCurrentProjectManager />" _ & "</ProjectServerSettingsRequest>") MsgBox xmlStream Else MsgBox "This macro returns information from Microsoft Project " _ & "Server. Please choose 'Collaborate using Microsoft Project " _ & "Server' and specify a valid Microsoft Project Server URL " _ & "for this project in Collaboration Options (Collaborate menu)." Exit Sub End If End Sub