使用 python 在 excel 上加载 Bloomberg 插件时遇到问题 [英] Trouble loading Bloomberg addins on excel using python

查看:87
本文介绍了使用 python 在 excel 上加载 Bloomberg 插件时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试打开一个连接到 BBG 和刷新值的 excel.

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

为了打开excel实例并加载bloomberg插件,我不久前使用了附加链接中的解决方案Python 使用 win32com 不会更新需要添加的 Excel 表-ins

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

该解决方案对我来说一直很好,直到今天由于某种原因 xlapp.RegisterXLL('C:/blp/API/Office Tools/bofaddin.dll') 给我带来了麻烦.即不加载和崩溃我的代码.

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

推荐答案

尝试导入 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')

这篇关于使用 python 在 excel 上加载 Bloomberg 插件时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆