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
- 6 AHS
- 37 Alpha
- 161 App Studio
- 4 Block Chain
- 4 Bot Platform
- 16 Connected Risk APIs
- 47 Data Fusion
- 30 Data Model Discovery
- 608 Datastream
- 1.3K DSS
- 577 Eikon COM
- 4.9K Eikon Data APIs
- 7 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- Trading API
- 2.7K Elektron
- 1.3K EMA
- 236 ETA
- 519 WebSocket API
- 33 FX Venues
- 10 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 20 Messenger Bot
- 2 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 59 Open Calais
- 264 Open PermID
- 39 Entity Search
- 2 Org ID
- PAM
- PAM - Logging
- 8.4K Private Comments
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 20 RDMS
- 1.4K Refinitiv Data Platform
- 367 Refinitiv Data Platform Libraries
- 3 Refinitiv Due Diligence
- LSEG Due Diligence Portal API
- 3 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.1K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 10 World-Check Customer Risk Screener
- 990 World-Check One
- 44 World-Check One Zero Footprint
- 45 Side by Side Integration API
- Test Space
- 3 Thomson One Smart
- 1.2K TR Internal
- Global Hackathon 2015
- 2 Specialists Who Code
- 10 TR Knowledge Graph
- 150 Transactions
- 142 REDI API
- 1.7K TREP APIs
- 4 CAT
- 21 DACS Station
- 117 Open DACS
- 1.1K RFA
- 103 UPA
- 172 TREP Infrastructure
- 224 TRKD
- 886 TRTH
- 5 Velocity Analytics
- 5 Wealth Management Web Services
- 59 Workspace SDK
- 9 Element Framework
- 5 Grid
- 13 World-Check Data File
- Yield Book Analytics
- 46 中文论坛