Events

An event can occur (fire) when an object does something as the result of a method or user action, which can trigger the event. Sometimes, several events can fire in sequence. Events can contain calls to methods, which can then cause even more events to fire.

For example, when the following code creates a new task, it triggers the Application object's ProjectBeforeTaskNew event:

ActiveProject.Tasks.Add "Write chapter", 3

If you want to prevent the task from being created, you can use the event's Cancel argument to do so.

In another example, closing Microsoft Project with an unsaved project file open causes several events of the Project object to fire:

Project_BeforeSave. This fires just before Microsoft Project asks if you want to save the project.

Project_BeforeClose. This fires just before the project closes. Project_Deactivate. This fires as the closing project is about to lose focus.

Note Several Application-level events also fire in this example.

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