[IronPython] events in PowerPoint

Curt Hagenlocher curt at hagenlocher.org
Wed Jun 25 03:21:28 CEST 2008

There's a reference for the TextRange object at
http://msdn.microsoft.com/en-us/library/bb251500.aspx.  It doesn't look like
it supports any events.  From what I can tell, all the events for PowerPoint
are defined on the Application object:
http://msdn.microsoft.com/en-us/library/bb251405.aspx.  Perhaps the
WindowSelectionChange event will do what you want.

On Tue, Jun 24, 2008 at 4:51 PM, Julien Sylvestre <jusylves at videotron.ca>

> Hello,
>  I'm new at Ironpython, I've been looking at a way to interact dynamically
> with PowerPoint.
> I got some simple code to work to access the text in a box which is
> selected in PowerPoint:
> import clr
> from System.Runtime.InteropServices import Marshal
> clr.AddReference("Microsoft.Office.Interop.PowerPoint")
> import Microsoft.Office.Interop.PowerPoint as PowerPoint
> ppt = Marshal.GetActiveObject("PowerPoint.Application")
> sel = ppt.ActiveWindow.Selection.TextRange
> print sel.Text
> This is nice, because if I change the text that was initially selected in
> PowerPoint, and do "print sel.Text" again, I get the updated text in Python
> (i.e., I get a reference to the TextRange object, which I can interogate
> with the Text method when changes are made in PowerPoint).
> My question is: is there a way to register an event handler to do some
> action automatically when the text is modified in PowerPoint? Ideally, I'd
> like my Python script to execute some actions whenever the TextRange object
> is modified in PowerPoint. If that's not feasible, I could also run those
> actions when the user does something particular (like changing his
> selection, or saving his PPT file).
> I've been trying to introspect my Python objects, but couldn't locate
> anything that would allow me to setup my event handler.
> Any comment or suggestion would be greatly appreciated.
> Thanks,
> Julien.
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080624/c35960d0/attachment.html>

More information about the Ironpython-users mailing list