PRJ: Running a Macro Automatically When You Start MS Project

Last reviewed: September 26, 1997
Article ID: Q128622
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
  • Microsoft Project for Macintosh, version 4.0

SUMMARY

To make a macro run automatically whenever the Microsoft Project icon is used to start Microsoft Project, edit the command line for the icon's properties so that a project containing an Auto_Open macro is opened automatically at startup. On the Macintosh, open the file which contains an Auto_Open macro.

MORE INFORMATION

The following steps will cause an Auto_Open macro to be executed only if you start Microsoft Project by double-clicking the Microsoft Project icon or on the Macintosh, double-clicking the Microsoft Project file which contains the Auto_Open macro.

  1. Create a new project.

        NOTE: For this example, the project is named as STARTUP.MPP, but you
        can use any valid filename.
    

  2. From the Tools menu, choose Macros, and choose the New button. Choose Options, and under Store Macro In, select Current Project File.

  3. In the Macro Name box, type "Auto_Open" (without the quotation marks), and Choose OK.

  4. In the Module Editor, enter the code that you want to be run each time Microsoft Project is started.

        NOTE: The Auto_Open macro can also run other macros. For example, if
        there is only one macro in GLOBAL.MPT called "MyStartup," and if it
        takes no arguments, then Auto_Open can run it using: Macro "MyStartup"
    

  5. From the File menu, choose Save to save changes to STARTUP.MPP, and quit Microsoft Project.

  6. Note: This step is for Microsoft Windows only. In Program Manager, select the Microsoft Project icon and from the File menu, and choose Properties. Edit the command line such that STARTUP.MPP is included in the command line. The command line should resemble the following:

          c:\winproj\winproj.exe c:\data\Startup.mpp
    

  7. Choose OK.

If you do not want the Auto_Open macro in STARTUP.MPP to be run, press and hold the SHIFT key when you start Microsoft Project.

Microsoft Project does not automatically create a blank Project1 when the icon is set up to automatically open a project. To create a new project, you can use the FileNew method in the Auto_Open macro in STARTUP.MPP.

If want to close STARTUP.MPP after you start Microsoft Project, add code to the Auto_Open macro to close it. For example, the following lines activate STARTUP.MPP and then close it without saving changes:

   Projects("Startup.mpp").Activate
   FileClose save:=pjDoNotSave

For additional information, please see the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q126105
   TITLE     : "Auto_Open and Auto_Close Macros"


Additional query words: 4.00
Keywords : kbcode kbprg
Version : 4.0 4.1 98
Platform : MACINTOSH WINDOWS
Issue type : kbhowto


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: September 26, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.