Export (0) Print
Expand All

ServerURL Property 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 example
Use a macro to determine whether a value is specified for a Microsoft Project Server URL
ServerURL property sample code

Overview

The following sample checks to see whether a Microsoft® Project Server URL is specified in Collaboration Options (Collaborate menu). If no URL has been specified, Microsoft Project displays an error message and launches the Options dialog box with the Collaborate tab selected. If a URL has been specified, Microsoft Project switches to a Resource Sheet view and displays the Build Team from Microsoft Project Server dialog box, if connected to My Computer in workgroup mode. Microsoft Project displays the Build Team from <Project Name> dialog box when connected to Microsoft Project Server. (3 pages)

Requirements

  • Microsoft Project Professional 2002 and Microsoft Project Server 2002

Running the code example

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 (either 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 determine whether a value is specified for a Microsoft Project Server URL

You can copy and paste the Microsoft VBA code below.

Notes   
  • If you have already entered a Microsoft Project Server URL for your project in Collaboration Options, you could also use this property to verify a specific Microsoft Project Server URL before Microsoft Project displays the Build Team from Microsoft Project Server dialog box if connected to My Computer in workgroup mode. Microsoft Project displays the Build Team from <Project Name> dialog box when connected to Microsoft Project Server.
  • If you are not connected to a valid and functioning Microsoft Project Server, or if you are working offline, Microsoft Project returns a trappable error (error code 1100) when running the AddResourcesFromProjectServer method.

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.

ServerURL property sample code

Sub IsServerNull()
   If Projects.Count = 0 Then
      MsgBox "You must have at least one active project open."
      Exit Sub
   End If

   If ActiveProject.ServerURL = "" Then
      MsgBox "A Microsoft Project Server URL has not been " _
         & "specified." & Chr(13) & "Click OK to select " _
         & "'Collaborate Using Microsoft Project Server' and " _
         & "specify a valid URL in the Options dialog box " _
         & "(Tools menu)."
      Application.OptionsWorkgroup
   Else
      ActiveProject.MakeServerURLTrusted
      ViewApply Name:="Resource Sheet"
      Application.AddResourcesFromProjectServer
   End If
End Sub

Show:
© 2015 Microsoft