[IronPython] events in PowerPoint

Kelie kf9150 at gmail.com
Thu Jun 26 10:06:04 PDT 2008


Try the code below. It works in my test, using Microsoft Office 2003
and IronPython 2.

import time
import clr
from System.Runtime.InteropServices import Marshal
clr.AddReference("Microsoft.Office.Interop.PowerPoint")
import Microsoft.Office.Interop.PowerPoint as PowerPoint

def onWindowSelectionChange(selection):
    print "Window selection changed."

if __name__ == "__main__":
    ppt = Marshal.GetActiveObject("PowerPoint.Application")
    ppt.WindowSelectionChange += onWindowSelectionChange
    while True:
        time.sleep(1)


More information about the Users mailing list