Events in Microsoft Project

I found this very interesting Python script, which showes how to use Events in Microsoft Project with Python for Windows. Simply dispatch with an eventmanager class:

import win32com.client
import pythoncom

defaultNamedNotOptArg = pythoncom.Empty

class EventManager(object):
    def OnProjectBeforeSave(self, pj=defaultNamedNotOptArg, SaveAsUi=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg):
        print 'Project saved'
        pass
    def OnProjectBeforeClose(self, pj=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg):
        print 'Project closed'
        pass
    def OnProjectTaskNew(self, pj=defaultNamedNotOptArg, ID=defaultNamedNotOptArg):
        print 'Task created'
        pass
    def OnProjectBeforeTaskChange(self, tsk=defaultNamedNotOptArg, Field=defaultNamedNotOptArg, NewVal=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg):
        print 'Field %s of Task %s changed to %s'%(Field, tsk, NewVal)
        pass
    def OnProjectBeforeTaskDelete(self, tsk=defaultNamedNotOptArg, Cancel=defaultNamedNotOptArg):
        print 'Task %s deleted'%tsk
        pass

app = win32com.client.DispatchWithEvents('MSProject.Application', EventManager)
doc = app.ActiveProject
app.Visible=1