You are currently offline, waiting for your internet to reconnect

Your browser is out-of-date

You need to update your browser to use the site.

Update to the latest version of Internet Explorer

PRJ: Auto_Open and Auto_Close Macros

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article was previously published under Q126105
Summary
In Microsoft Project, when you use the Auto_Open or Auto_Close VisualBasic, Applications Edition, macro names, the macro will run either when afile is opened or when it is closed, respectively.

This behaviour does not work for embedded projects, or project files linked into other applications. Auto_Open/Auto_Close will not function in these cases.
More information
The following table shows the behavior of an Auto_Open or Auto_Close macro depending on whether the macro is located in a Microsoft Project MPP/MPT file or in GLOBAL.MPT. Note that Consolidated MPP is the same as a Master plan; the terminology changed with the release of 2002.

Auto_Open Macro

   Type of File Opening    Macro Location            Auto Macro Runs From   ----------------------------------------------------------------------   Normal MPP/MPT          GLOBAL.MPT                GLOBAL.MPT   Normal MPP/MPT          MPP or MPT                MPP/MPT   Normal MPP/MPT          GLOBAL.MPT and MPP/MPT    MPP/MPT   Foreign (MPX, CSV,      GLOBAL.MPT                GLOBAL.MPT   and so on)   3.0 MPV or MPC          GLOBAL.MPT                Does Not Run   Consolidated MPP        GLOBAL.MPT                Does Not Run   Consolidated MPP        MPP                       Does Not Run   Consolidated MPP        GLOBAL.MPT & MPP          Neither Macro Runs				

Auto_Close Macro

   Type of File Closing    Macro Location            Auto Macro Runs From   ----------------------------------------------------------------------   Normal MPP/MPT          GLOBAL.MPT                GLOBAL.MPT   Normal MPP/MPT          MPP or MPT                MPP/MPT   Normal MPP/MPT          GLOBAL.MPT and MPP/MPT    MPP/MPT   Foreign (MPX, CSV,      GLOBAL.MPT                GLOBAL.MPT   and so on)   3.0 MPV or MPC          GLOBAL.MPT                GLOBAL.MPT   Consolidated MPP        GLOBAL.MPT                GLOBAL.MPT   Consolidated MPP        MPP                       MPP   Consolidated MPP        GLOBAL.MPT & MPP          MPP				
NOTE: A major difference regarding consolidated project files and version3.0 MPV and MPC files is that when you open these files, Auto_Open macrosdo not run; however, when you close them, an Auto_Close macro WILL be runif one exists.

In addition, if an Auto macro exists within an MPP or MPT file, the macroswill not be run when you open or close a different file.
References
For more information about Creating A Sub Procedure That RunsAutomatically, choose Contents from the Help menu, choose Visual BasicReference, choose the Search button, and type:
Creating
Properties

Article ID: 126105 - Last Review: 04/29/2013 21:14:00 - Revision: 6.0

  • Microsoft Project 98 Standard Edition
  • Microsoft Project 4.1 Standard Edition
  • Microsoft Project 4.0 Standard Edition
  • Microsoft Office Project Professional 2007
  • Microsoft Office Project Professional 2003
  • Microsoft Office Project Server 2007
  • Microsoft Office Project Server 2003
  • Microsoft Office Project Standard 2007
  • Microsoft Office Project Standard 2003
  • Microsoft Project 2000 Standard Edition
  • Microsoft Project 2002 Standard Edition
  • Microsoft Project 2002 Professional Edition
  • Microsoft Project Professional 2010
  • Microsoft Project Standard 2010
  • Microsoft Project 2013 Professional
  • Microsoft Project 2013 Standard
  • kbcode kbinfo kbprogramming KB126105
Feedback