question

Upvotes
Accepted
3 1 1 4

Python win32com Refinitiv COMAddin not showing

I am struggling to use Refinitiv COMAddin programmatically on excel using python win32com (I have also tried with xlwings with no success).

If I open excel manually an excel file the "Refinitiv" tab works perfectly fine but it appears to crash when I open excel indirectly from python: this creates issues when I am trying to insert refinitiv api formulas in cells.

I have looked at this other post https://community.developers.refinitiv.com/questions/29464/launch-excel-com-add-in-with-python-win32com.html but it does not work for me since the following command prompts an error:

xlapp.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Connect = True

The code snippet I am using is the following

import win32com.client as win32
xlapp = win32.gencache.EnsureDispatch('Excel.Application')
xlapp.RegisterXLL(addin_path)
xlapp.Visible=False
wb = xlapp.Workbooks.Open(xlsPath,None,False)
sht = wb.Sheets('Sheet1')
sht.Cells(1,1).Value = formula_string


Where

formula_string: string containing the Refinitiv formula
xlsPath: path of the excel file I am opening
addin_path: path of the Refinitiv addin, which in my case is contained in  ...\AppData\Local\Refinitiv\Refinitiv for Office\1.19.98\Office_x64\refinitiv-shim.dll

Can anyone help me with this problem?

Thanks



#technologyapiexcelwin32
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
Accepted
78.6k 248 52 74

@bartolacci

Thanks for reaching out to us.

You may need to check if the Refinitiv Eikon - Microsoft Office is loaded properly

import win32com.client as win32
xlapp = win32.gencache.EnsureDispatch('Excel.Application')
xlapp.Visible=False
for addin in xlapp.COMAddIns:
    print(addin.description)
    print(addin.connect)

The following code works on my machine.

import win32com.client as win32
xlapp = win32.gencache.EnsureDispatch('Excel.Application')
xlapp.Visible=False


for addin in xlapp.COMAddIns:
    print(addin.description)
    print(addin.connect)
    
xlsPath = "C:\\Users\\U8009686\\eikonscripting\\Book.xlsx"
wb = xlapp.Workbooks.Open(xlsPath,None,False)


xlapp.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Connect = True


formula_string = '=@TR("CNY=","DSPLY_NAME","CH=Fd RH=IN",B2)'
sht = wb.Sheets('Sheet1')
sht.Cells(1,1).Value = formula_string


wb.Save()
xlapp.Application.Quit()

However, if you would like to use Python to retrieve the data, it is better to use Eikon Data API or Refinitiv Data Library for Python. Then, save the retrieved data to an Excel file.

Otherwise, you can try the xlwings Python library.

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
3 1 1 4

@Jirapongse

thank you for the complete answer and the very useful links you provided.

Unfortunately, the example you gave does not work on my machine, since the line:

xlapp.COMAddIns("PowerlinkCOMAddIn.COMAddIn").Connect = True

trigger an error on my console:

"This addin is installed for all the users and can be connected/disconnected only by an administrator"

The point is that I am currently an admin on my machine, and even launching python as administrator, I get the very same error, which is kind of confusing to me.

--------------------------------------------------------------------------------

In the meantime I would like to add another question which came to my mind after reading your links.

The refinitiv-dataplatform python package (https://pypi.org/project/refinitiv-dataplatform/) basically replicates what can be done in excel using the addin on the button below

1673604639492.png


Is there any similar official python package for the Datastream part of the ribbon, as below?

1673604700291.png

Thank you


1673604639492.png (10.1 KiB)
1673604700291.png (9.7 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Upvotes
78.6k 248 52 74

@bartolacci

Yes, the Refinitiv Data Library for Python (https://pypi.org/project/refinitiv-data/) can retrieve fundamental data, real-time data, and time-series data which is similar to Eikon Excel Addin (Formula Builder).

For the Datastream formula, you can use DatastreamPy (https://pypi.org/project/DatastreamPy/)

icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.