VBA:等待彭博 BDP 调用完成

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4298934/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 12:21:21  来源:igfitidea点击:

VBA: Waiting for Bloomberg BDP calls to finish

vbaexcel-vbabloombergexcel

提问by Martin

I have a script that imports some external data into the worksheet, which in turn affects some =BDP(...)formulas. Optimally, I'd like to do some checks on the BDP results immidiately after copying the data.

我有一个脚本将一些外部数据导入到工作表中,这反过来又会影响一些=BDP(...)公式。最理想的是,我想在复制数据后立即对 BDP 结果进行一些检查。

The Bloomberg Excel Add-in updates asynchronously - how do I wait for the results and then resume the script? It seems that the results are only imported after the VBA script finishes, no matter how long it runs.

Bloomberg Excel 插件异步更新 - 如何等待结果然后恢复脚本?似乎只有在 VBA 脚本完成后才导入结果,无论它运行多长时间。

Thanks in advance Martin

提前致谢马丁

回答by Chris Spicer

I built something similar using BDH. I had to release control so that the Bloomberg add-in can go and collect the data, then resume my code. I was able to do this using Application.OnTime.

我使用 BDH 构建了类似的东西。我不得不释放控制权,以便彭博插件可以去收集数据,然后恢复我的代码。我能够使用 Application.OnTime 做到这一点。

For example, if you have a 'CheckForData' function that affects the =BDP calls, and another function called 'ProcessData' that checks the results, make an aynchronous call to to 'ProcessData' within 'CheckForData', e.g.

例如,如果您有一个影响 =BDP 调用的“CheckForData”函数,以及另一个检查结果的名为“ProcessData”的函数,则在“CheckForData”中异步调用“ProcessData”,例如

Sub CheckForData
  ' Your code here
  Application.OnTime Now + TimeValue("00:00:05"), "ProcessData"
End Sub

Then within 'ProcessData' perform your checks.

然后在“ProcessData”中执行您的检查。