[IronPython] events in PowerPoint

Julien Sylvestre jusylves at videotron.ca
Thu Jun 26 02:09:20 CEST 2008

I've sent the following this morning, but the message appeared all 
scambled in the mailing list's archive (was testing a new mail client), 
and I'm afraid it didn't make it in an intelligible manner to people on 
the list. My most sincere apologies for cluttering your mailboxes.


Thanks for the quick reply.
The line
ppt.WindowSelectionChange += onWindowSelectionChange
doesn't work for me.
It looks like my ppt object (type __ComObject) doesn't have 
the WindowSelectionChange attribute (see below for a dir on my ppt 
object). I've looked at other objects in ppt (ActiveWindow, 
ActiveWindow.Application, etc.), and I can't find WindowSelectionChange 
(or any other event) anywhere by running recursive dir() on my ppt 
object and its attributes.
I'm puzzled. My ppt object probably isn't the Application object to 
which event handlers are attached (I'm ashamed to say that I'm not sure 
what class my ppt object is instantiated from, or what's the type of its 
attributes). Or maybe I need to do something particular to enable events?
Any help would be greatly appreciated.
Many thanks,
dir(ppt), where ppt = Marshal.GetActiveObject("PowerPoint.Application")
['Activate', 'Active', 'ActivePresentation', 'ActivePrinter', 
'ActiveWindow', 'A
ddIns', 'AnswerWizard', 'Assistant', 'AutoCorrect', 
'AutomationSecurity', 'Build
', 'COMAddIns', 'Caption', 'CommandBars', 'CreateObjRef', 'Creator', 
Options', 'Dialogs', 'DisplayAlerts', 'DisplayGridLines', 'Equals', 
all', 'FileFind', 'FileSearch', 'Finalize', 'GetHashCode', 
 'GetOptionFlag', 'GetType', 'HWND', 'Height', 'Help', 
e', 'LanguageSettings', 'LaunchSpelling', 'Left', 'Marker', 
'MemberwiseClone', '
MsoDebugOptions', 'Name', 'NewPresentation', 'OperatingSystem', 
'Options', 'PPFi
leDialog', 'Path', 'Presentations', 'ProductCode', 'Quit', 'Run', 
', 'SetPerfMarker', 'ShowStartupDialog', 'ShowWindowsInTaskbar', 
ws', 'ToString', 'Top', 'VBE', 'Version', 'Visible', 'Width', 
'WindowState', 'Wi
ndows', '__class__', '__doc__', '__init__', '__module__', '__new__', 
', '__reduce_ex__', '__repr__']

Kelie wrote:
> Not sure if this will help. I wrote something like this a while back,
> probably using IronPython 1.1. And it was for a different software.
> 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")
> def onWindowSelectionChange(selection):
>     print "Window selection changed."
> ppt.WindowSelectionChange += onWindowSelectionChange
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

More information about the Ironpython-users mailing list