MakeServerURLTrusted 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 example
Use a macro to make a Microsoft Project Server URL trusted
MakeServerURLTrusted method sample code

Overview

The following sample adds the URL specified in Collaboration Options (Collaborate menu) to the list of trusted sites in Microsoft® Internet Explorer. Upon confirmation, 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 make a Microsoft Project Server URL trusted

You can copy and paste the Microsoft VBA code below.

**Notes   **

  • If you have already added the Microsoft Project Server URL for your project to Microsoft Internet Explorer's list of trusted sites, 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 the Microsoft Project Server URL is not among the list of trusted sites in Microsoft Internet Explorer, Microsoft Project displays a message box confirming the addition before proceeding.
  • 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.

MakeServerURLTrusted method sample code

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