Integrating Your Form into Microsoft Project

You now have a form with controls and event procedures that perform actions when the controls are used, but no one will ever see the form until you determine how the form is activated. With many types of forms, it's enough that the user runs a macro, which then displays one or more forms as it runs.

For this form, though, you want to automatically display the form every time a particular plan is opened. Follow these steps to create an event procedure for the Project object that will display your form every time the plan is opened:

1 In the Project Explorer, double-click ThisProject. The Code window opens.

2 In the Objects box, click Project, and then type the following code into the Project object's Open event:


3 In the Procedure/Events box, click BeforeClose and then type the following code into the Project object's BeforeClose event:

Application.StatusBar = False

Because code tied to the Project object is changing an application-level property, you need this additional code to "clean up" the effects of using the form by resetting the StatusBar property to its default value (see Figure 31-24).

Figure 31-24. The Microsoft Project status bar after someone has used the form.

Note The first form your users see when opening the plan is actually the macro virus security dialog box. If a user selects the Disable Macros button, none of the event procedures run and your form doesn't display.

For more information about Project events, see "Creating Project Event Procedures" earlier in this chapter on page 921.

Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment