Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

GetProjectServerSettings Method Example for Microsoft Project Server 2002

This 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.
 

Randall Isenhour
Microsoft Corporation

August 2002

Contents

Overview
Requirements
Running the code sample
Use a macro to retrieve Microsoft Project Server settings for a project
GetProjectServerSettings method sample code

Overview

The following sample returns an XML stream representing the following settings from Microsoft® Project Server (4 pages):

  • 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>
    
    

Requirements

  • Microsoft Project Standard 2002 or Microsoft Project Professional 2002, in addition to Microsoft Project Server

Running the code sample

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.

Use a macro to retrieve Microsoft Project Server settings for a 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

  1. On the Tools menu, point to Macro and click Macros.
  2. Type a name for your new macro in the Macro name box.
  3. Select the project where you wish to create the macro in the Macros in box.
  4. Click Create.

GetProjectServerSettings method sample code

Sub mpsSettings()
   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


Show: