Trouble loading Bloomberg addins on excel using python

纵饮孤独 提交于 2020-06-17 15:47:08

问题


I am trying to open an excel which is connected to BBG and refresh values.

To open an instance of excel and load bloomberg addins, I used a solution from the attached link a while ago Python using win32com wont update excel sheet with needed Add-ins

The solution worked fine for me till yday when for some reason xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll') is giving me trouble. i.e. not loading and crashing my codes.

Anyone has any ideas whats happening?

Codes are below if anyone interested

import os, os.path
import win32com.client

xlapp = win32com.client.DispatchEx("Excel.Application")
xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
xlapp.Workbooks.Open('C:\\blp\\API\\Office Tools\\BloombergUI.xla')
wb = xlapp.Workbooks.Open(filepath,None,False)
xlapp.Visible = True
wb_addin = ('C:/blp/API/Office Tools/bofaddin.dll')
wb.RefreshAll()

回答1:


Try importing time and putting time.sleep(2) after each command. I found the Bloomberg links sometimes need a second to update.

xlapp = win32com.client.DispatchEx("Excel.Application")
time.sleep(2)
xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll')
time.sleep(2)
xlapp.Workbooks.Open('C:\\blp\\API\\Office Tools\\BloombergUI.xla')
time.sleep(2)
wb = xlapp.Workbooks.Open(filepath,None,False)
xlapp.Visible = True
wb_addin = ('C:/blp/API/Office Tools/bofaddin.dll')


来源:https://stackoverflow.com/questions/62320267/trouble-loading-bloomberg-addins-on-excel-using-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!