Using the Project.Open Event

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Microsoft Office Project 2007 no longer supports the AutoOpen macro. Instead, you can use the Project.Open event. Different Project_Open event handlers can run, depending on whether you are connected to Microsoft Office Project Server 2007.

In the Visual Basic Editor, expand all of the nodes in the left pane to see the location of the ThisProject object in each project. You can put different Project_Open event handlers in ThisProject objects in each of the following nodes.

  • VBAProject (Project name.mpp) You can save a Project_Open event handler in each project that runs when you open the project. You can be connected to Project Server or not, and the project can be stored on the local computer, on a file share, in a Shared Documents library in Windows SharePoint Services, or in Project Server.

  • ProjectGlobal (Global.MPT) The Project_Open event handler in the global template runs only when you are not connected to Project Server and when you open any project stored on the local computer, on a file share, or in a Shared Documents library in Windows SharePoint Services. The following code example displays a message on when Project starts up, and a different message when you open a project.

    Sub Project_Open(ByVal pj As Project)
        If (pj Is Nothing) Then
            MsgBox "Called Project_Open from Global.MPT."
        Else
            MsgBox "Global.MPT: Opened project: " & pj.Name
        End If
    End Sub
    
  • VBAProject (Global (+ non-cached Enterprise)) The Project_Open event handler in the enterprise project template runs only when you are connected to Project Server and when you open any project. The project can be local, on a file share, in a Shared Documents library in Windows SharePoint Services, or opened from Project Server. The following code is similar to the previous example, but displays different messages from the enterprise global template.

    Sub Project_Open(ByVal pj As Project)
        If (pj Is Nothing) Then
            MsgBox "Called Project_Open from EGlobal."
        Else
            MsgBox "EGlobal: Opened project: " & pj.Name
        End If
    End Sub
    

See Also

Concepts

Changes for Custom Project Guides