In Project 2013 and 2010 use the following steps:
- Create a new project. Note: for this example, the project is named as STARTUP.MPP, but you can use any valid filename.
- From the View menu, choose Macros, and click View Macros.
- Begin to type a new name for the macro called "Auto_Open" and click Create. Microsoft Visual Basic For Applications window will launch.
- In the VBA editor, enter the code that you want to be run each time Microsoft Project is started.
- From the editor's File menu, choose Save STARTUP.MPP, from the File menu click Close and Return to Microsoft Project.
- Save the plan and Close Microsoft Project. The next time you open this plan the Auto_Open macro will run if you answer Yes to enable macros.
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"
- Create a shortcut on your desktop for Microsoft Project. The executable is called WINPROJ.EXE.
- Right click the shortcut and click Properties. In Target, append the path to your saved plan STARTUP.MPP. For example: c:\winproj\winproj.exe c:\data\Startup.mpp. click OK.
Follow these steps for earlier versions of Microsoft Project
- Create a new project. NOTE: For this example, the project is named as STARTUP.MPP, but you can use any valid filename.
- From the Tools menu, choose Macros, and choose the New button. Choose Options, and under Store Macro In, select Current Project File.
- In the Macro Name box, type Auto_Open and Choose OK.
- Follow steps 4 through 8 above.
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:
For additional information, please see the following article in the Microsoft Knowledge Base:
文章 ID：128622 - 上次审阅时间：2013年4月26日 - 修订版本： 1