Excel Bloomberg API callback in macro

守給你的承諾、 提交于 2019-12-25 12:48:11

问题


I have a cell utilizing a Bloomberg API function and looping through inputs using a macro, but I want the loop to wait for the Bloomberg function to produce a result before proceeding (basically a callback). Is there a straightforward way of accomplishing this?


回答1:


You can try something like this:

Sub Main()

'Write API Formulas
Range("B1:C10000").Formula = "=bdp(""MSFT Equity"",""SECURITY_NAME"")"

'Check to see if it filled
Call Check_API

End Sub


Sub Check_API()

If Application.WorksheetFunction.CountIfs(Range("B1:C10000"), "#N/A Requesting Data...") > 0 Then
    'Check every 3 seconds
    Application.OnTime Now + TimeValue("00:00:03"), "Check_API"
Else
    'Do what you want after api has loaded
    MsgBox "Done"
End If

End Sub


来源:https://stackoverflow.com/questions/33900687/excel-bloomberg-api-callback-in-macro

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