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
Best Answer
-
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.
0
Answers
-
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
Is there any similar official python package for the Datastream part of the ribbon, as below?
Thank you
0 -
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/)
0
Categories
- All Categories
- 3 Polls
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 34 Data Model Discovery
- 685 Datastream
- 1.4K DSS
- 615 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 252 ETA
- 556 WebSocket API
- 38 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.9K Refinitiv Data Platform
- 652 Refinitiv Data Platform Libraries
- 4 LSEG Due Diligence
- LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 27 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 193 TREP Infrastructure
- 228 TRKD
- 917 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 90 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛