且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用 python 在 excel 上加载 Bloomberg 插件时遇到问题

更新时间:2023-02-26 18:57:18

尝试导入 time 并将 time.sleep(2) 放在每个命令之后.我发现彭博链接有时需要一秒钟才能更新.

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')