[IronPython] Excel events from IronPython?
Christian Muirhead
christian.muirhead at resolversystems.com
Thu May 24 15:11:14 CEST 2007
Hi -
I'm automating Excel from IP, which has been a bit painful, but looks to
be working now. One extra thing I'd like to do is to subscribe to a
worksheet's change event.
This (http://support.microsoft.com/kb/302815/) is an article that does
in C# essentially what I'd like to do in IP. I can construct an
AppEvents_SheetChangeEventHandler delegate wrapped around a function,
but I can't find the event to hook it up - there's no .Change event on
the worksheet.
Nosing around the Microsoft.Office.Interop.Excel namespace (the Excel
object model documentation is pretty patchy, although I've looked there
too), I can see a type called AppEvents_Event, which does seem to expose
the events I want. But I can't work out how to instantiate it (or even
whether I should be trying to), and trying to attach the delegate to the
event on the type results in:
>>> Excel.AppEvents_Event.SheetChange +=
Excel.AppEvents_SheetChangeEventHandler(func)
Traceback (most recent call last):
File , line 0, in <stdin>##165
StandardError: Non-static method requires a target.
(Which is pretty clear.)
I'm about to try following the example in C#, and hopefully I'll be able
to work out what the C# code's doing differently.
In the meantime, has anyone successfully consumed Excel (or any Office
application) events in IronPython? Can anyone familiar with COM<->.NET
interop see what I should be doing?
Thanks,
Christian
--
Christian Muirhead
Resolver Systems
christian.muirhead at resolversystems.com
Office address: 17a Clerkenwell Road, London EC1M 5RD, UK
Registered address: 843 Finchley Road, London NW11 8NA, UK
Resolver Systems Limited is registered in England and Wales as company
number 5467329.
VAT No. GB 893 5643 79
More information about the Ironpython-users
mailing list