Excel RTD server in Python does not update data

I have excelRTDserver.py and it works in Excel 2010 (32 bit) by changing the value of EXCEL_TLB_MINOR to 7 . I can see the server in the list of add-ons, and if I type =RTD("Python.RTD.TimeServer","","seconds","5") in the cell, I get the current time. But it is never updated. If I change β€œ5” to another number, I get an update, but after the initial change it never changes again.

How do I update it? I found someone else with a similar problem here , but no solution.

UPDATE: I have a little more - an exception is thrown in ServerStart when you throw a PyIDispatch callback object into an IRTDUpdateEvent callback object. Using this method to fix the error message, I get: "Unable to create file if this file already exists." If I follow the suggestion here and use win32com.client.CastTo(CallbackObject,'IRTDUpdateEvent') , I get "This COM object cannot automate the makepy process - start makepy manually for this object", but I already ran makepy for the Microsoft object library Excel 12.0 (1.6).

Any help would be greatly appreciated.

+8
python excel com rtd
source share
4 answers

I think you might be out of luck.

According to the author excelRTDServer.py in a recent python-win32 thread :

The message is that this is in response to your specific problem, and the latter, so maybe you already received this information directly, but in case you don’t ...

I am afraid that things with IRTDUpdateEvent have changed with recent versions from excel (since Excel 2007? I think that is not so "recent" anymore ...).

While searching for news about interface changes, I came across this thread in the java forum:

http://www.nevaobject.com/phpbb3/viewtopic.php?t=516

The part that excites me is the comment:

"Apparently, in Excel 12 (Excel 2007), the RTD callback object that implements the IRTDUpdateEvent dual interface throws an exception (general COM exception 0x80020009) when called through IDispatch. If you use the v-table bind the UpdateNotify call to success. I really don't know if this is an error in Excel 12 or a function.

So far, I have not been able to confirm this with regard to the MSDN information ... But if so, this explains the problem. The examples are much older on the Internet, and pywin32 + makepy treats this interface as an IDispatch, and wrap it accordingly.

I do not think we can fix this with pywin32, as of now. my understanding is that it relies on IDispatch support. It may take comtypes (http://starship.python.net/crew/theller/comtypes/) to wrap (new?) IRTDUpdateEvent objects, or possibly a C .: extension

+3
source share

To get around this problem, I created a new project for github for excel types for pythoncom:

https://github.com/pyxll/exceltypes

This includes a slightly modified version of excelRTDServer.py , which uses the new type PyIRTDUpdateEvent instead of the win32com makepy shell, and so it now works in Excel 2010 (find the comments 'EXCELTYPES_MODIFICATION' in exceltypes/demos/excelRTDServer.py ).

To create a project, you will need a visual studio (it will not be built using gcc), and you can create it using setup.py, which is included in the project, as follows:

 python setup.py install 

If you need to force to use visual studio instead of gcc, use the parameter "--compiler=msvc" if you use anaconda, for example. If you want to use Visual Studio 2012 instead of 2010 by default, add the following lines to setup.py :

 from distutils import msvc9compiler msvc9compiler.VERSION = 11 
+3
source share

Python:

I get "This COM object cannot automate the makepy process - start makepy manually for this object", but I already performed makepy for the Microsoft Excel 12.0 (1.6) object library.

Yesterday at work, after some time, reading your question, I forgot that it is python, not java :)) .. Well, now the only thing I think is that you need to run PIA for the 2010 office.

Edit later: if you have problems after what I told you, comment, not downvote, because this problem is unusual.

JAVA:

This is because there is no way to generate v-tables .

You need to change the ServerStart method, as well as the IRTDServer interface and the IRTDServer_Impl class ., Therefore CallbackObject is COMIUnknown . Then you need to generate the IRTDServer_Skel class by running IBuilder.

Now you can create a new java shell for IRTDUpdateEvent to query the v-table:

enter image description here

+1
source share

Sometimes this error message occurs when u puts it in something like a "for'-loop", here is a 4u hacking solution: import time and using "sleep ()" in your loop

0
source share

All Articles