4

I'm using Reuters integrated in Excel to retrieve market data. For task automation , I currently use VBA but now I want to switch to python. The package pyxll does not help much because the principle is the same as VBA (I need to be inside Excel and click on the RUN button...) So I'm considering using win32com to access to Excel from outside with COM object. However, when I do:

from win32com.client import Dispatch 
xlApp = Dispatch("Excel.Application")

This code opens a new instance of Excel that does not have Reuter add-in in there (thus I can't use the Reuter function to retrieve data). I don't know how to access to Excel-with-Reuter instance from python? I've taken a look at Com Explorer to explore the service and I didn't see any other service than Excel

nam
  • 3,542
  • 9
  • 46
  • 68
  • Can you control the excel instance you open? If so, then I think the solution might be as simple as telling excel to open whatever.xll to load the Reuter's addin. – BenDundee Apr 10 '13 at 15:16
  • The problem is that there is no .xll file, this is the addin written in Dotnet, I just don't know how the application is launched – nam Apr 10 '13 at 15:44
  • How do you launch the application? – pyrospade Apr 11 '13 at 14:47
  • That's my question too. There is a shortcut in desktop but I can't read to see inside this binary file where is the executable – nam Apr 11 '13 at 14:54
  • Does the Reuters .NET app have a COM interface? You say you currently use VBA, so what does the VBA code look like that allows you to access the Reuters app? – Michael David Watson Apr 17 '13 at 22:46
  • The VBA code cal call the Excel function and Reuters function. Because this VBA code is executed inside Excel-Reuters. I think Reuters does not allow Excel to provide COM interface (maybe they can sell this option more expensive?) – nam Apr 18 '13 at 09:06
  • I just remembered about this question, as it peaked my interest. Can you post your solution, or at least a psuedo solution in an edited version of your question? – Michael David Watson May 15 '13 at 23:13
  • Can you please look into my Python question. [https://stackoverflow.com/questions/43456749/automate-the-process-of-refresh-in-excel-while-connecting-to-teradata-using-pyth][1] – deeps Apr 17 '17 at 19:19

4 Answers4

3

Try this -

import os
from win32com.client import GetObject

os.startfile(r'C:\path\to\ReutersExcel.exe')
xlApp = GetObject(None, 'Excel.Application')
pyrospade
  • 7,870
  • 4
  • 36
  • 52
  • Thanks a lot, that's a lot of time you saved me (and my company)? Thomson Reuters guy must be sad ;-) – nam May 03 '13 at 12:54
  • @pyrospade Can you add more detail to your answer? GetObject is not very common and I would love to get your take on how/when to use it. – Michael David Watson May 15 '13 at 23:16
  • 1
    `Dispatch()` is used to create a new COM instance; `GetObject()` is used to get an existing COM instance. The trick here was to open the application via an OS call than retrieve the instance. – pyrospade May 16 '13 at 03:34
  • So then he is still accessing the Excel.Application Object and accessing the Add-On through there? Does this then assume that he could have started Excel, launched the app and called: `xl = win32com.client.Dispatch("Excel.Application")`; `xlWbk = xl.ActiveWorkbook` and done the same thing? – Michael David Watson May 16 '13 at 16:04
  • Correct. He would just have to use the Excel COM API. – pyrospade May 16 '13 at 16:34
  • If I have 2 instances of Excel opened, can GetObject distinguish between these two? – nam Sep 17 '13 at 13:28
  • Not really. Hit google for "vba getobject multiple instances". Here's a decent one - http://www.pcreview.co.uk/forums/getobject-more-than-1-excel-running-t3575757.html - In this particular scenario you are invoking Excel yourself, so it would probably be a good idea to kill any existing Excel processes before using `os.startfile()`. – pyrospade Sep 17 '13 at 16:25
2

If you're using Excel to access Thomson Reuters Dataworks Enterprise (former Datastream), then have a look on pydatastream (https://github.com/vfilimonov/pydatastream) - it'll allow you to get the data directly to python in pandas.DataFrame format.

Vladimir
  • 1,363
  • 2
  • 14
  • 28
1

If you are using Excel VBA, it is have a very high chance for an incorrect result (You also have a very hard time to write more codes to handle states that might cause the problem as well).

From my experience, we should consume the data directly from the feed and manipulate it. It is easily to maintain as well as reliable (Definitely I do this in python).

I am using PyRFA to consume the data from my P2PS and manipulate it (This API is great as it currently free of charge! it provides both consumer and provider capability). Here's more detail of this API:

http://www.devcartel.com/pyrfa

What you need to do is contacting to their support team for more details and boom coding begin!

Cheers, Michael

  • Thanks for advice but in my Company we only have the Excel interface for retrieve datas, for other services we may pay more... – nam Sep 17 '13 at 13:42
1

you can launch the add-ins with this code: make sur before you have the automatic sign-in selected.

Import win32com.client
xl = win32com.client.DispatchEx("Excel.Application")