question

Upvotes
Accepted
1 0 0 1

eikon data on excel not working when launched with python

Hi,


I have an excel file with eikon formulas and macros to update spot, swap points and do some math etc... I would like to launch that excel file using Python and execute the excel's macros also with Python. Manually everything works but when I use Xlwings or win32com to launch the excel with python, the dates are 00/01/1900 and every FX spot is at 0 and when I try to refresh manually or with python nothing works.

The Add in is connected and I am logged in so it should work.


My python script works when I open and run macro on excel that do not use eikon data.


import xlwings
import time

def run_macro (work_book_path: str, *args: str):
    """Run macro from a workbook

    Args:
        work_book_path (str): macro's name
    """
    wb = xlwings.Book(work_book_path)

    time.sleep(10)

    for macro in args:
        print(f"running {macro}")
        running_macro = wb.macro(macro)
        running_macro()
        time.sleep(3)

run_macro(PATH_UMILP_P2, 
          "Module1.macro1", 
          "Module1.macro2", 
          "Module1.macro3",
          "Module1.macro4"
          )
python#technologydataexcel
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.

1 Answer

· Write an Answer
Upvote
Accepted
87.3k 294 53 79

@mathieu.nunessanches

Thank you for reaching out to us.

When you run Excel from scripts, the Eikon Excel Add-ins may not be loaded properly. Therefore, the macro that used Eikon Excel functions will not work.

1718766154807.png

You may check with the Eikon support team via MyRefinitiv to verify if the Eikon Excel can be run via scripts.

Instead of using Eikon Excel Add-ins with Xlwings, you can use the Refinitiv Data Libary for Python and then populate the retrieved data to Excel by using Xlwings. You can refer to the following articles:


1718766154807.png (29.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.

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.