PRJ: Auto_Open and Auto_Close Macros

Last reviewed: November 24, 1997
Article ID: Q126105
The information in this article applies to:
  • Microsoft Project 98 for Windows
  • Microsoft Project for Windows 95, versions 4.1, 4.1a
  • Microsoft Project for Windows version 4.0

SUMMARY

In Microsoft Project, when you use the Auto_Open or Auto_Close Visual Basic, Applications Edition, macro names, the macro will run either when a file 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. Also noted is behavior relating to consolidated project files and Microsoft Project version 3.0 MPV and MPC files.

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 version 3.0 MPV and MPC files is that when you open these files, Auto_Open macros do not run; however, when you close them, an Auto_Close macro WILL be run if one exists.

In addition, if an Auto macro exists within an MPP or MPT file, the macros will not be run when you open or close a different file.

REFERENCES

For more information about Creating A Sub Procedure That Runs Automatically, choose Contents from the Help menu, choose Visual Basic Reference, choose the Search button, and type:

   Creating


Additional query words: 4.00

Keywords : kbcode kbprg kbcode kbprg
Version : 4.00 4.1 4.1a 98
Platform : WINDOWS
Issue type : kbinfo


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 24, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.