[python-win32] Event problems in Excel 2007/Windows 7/Python 2.6
python-win32 at recluse.demon.co.uk
Fri Mar 18 19:47:38 CET 2011
I have Excel 2007 on Windows7 on a twin CPU machine and am trying to get
events to fire from the COM objects in win32com examples.
Specifically, when I load the excelAddin.py example, all looks good and
the Python menu item appears on the menubar (ribbon) but clicking on it
Trying the excelRTDserver.py example has similar problem - the time
comes up when I enter the formula in Excel and a bit of judicious
logging shows the Update function called like clockwork (;-) but the
SignalExcel() function has no effect - the time in Excel does not tick
and RefreshData is never called. I messed about with trying to capture
the Excel callback object thread and using CoInitialise and
CoGetInterfaceAndReleaseStream to get a reference to it on the Excel
original (COM) thread but this all had no effect (either through my
incompetence or failure of the approach to fix the problem). If I change
the formula in Excel to have a different timer period then it updates
the time once when I hit Enter then sits there unchanging again. The
Heartbeats are called (by Excel) and responded to as usual.
I tried to use the win32 timer example in place of the python Thread
timers but this just caused Excel to call ServerTerminate() on me so I
have obviously done something it finds offensive - I just get NA in
Excel after that.
I added the C:\Python26 directory and subdirs to the Trusted Locations
in Excel, and also the parent directory where I have my examples stored,
but to no avail.
Is anyone aware of some extra security or policy setting I need enabled
for these events to start working ?
Was I barking up the wrong tree with trying to get back to the calling
thread or is this at the heart of the problem and I just failed to
implement it properly ? There are examples of using the calling thread
in other examples but they are on the client side - the one that uses
internet explorer seems to work fine for me.
My ultimate goal is to link Excel to remote python processes using STOMP
on ActiveMQ. I can send STOMP messages from Excel via Python into my
ActiveMQ pipe with ease, and do 'synchronous' receives, using win32com
magic, and I can make the Excel async receives work after a fashion by
polling in a loop which includes DoEvents but this is not very
satisfactory - I really want to generate events from a Python COM object
on a message receive and use the RTD mechanism or something WithEvents
of my own devising, but I cannot make this work.
Any idea what has become broken in Excel/Windows/Python 2.6 ?
More information about the python-win32