在 vba 中使用彭博 API
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8729738/
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
Using the Bloomberg API in vba
提问by ecbtln
I am trying to load data with the bloomberg API using this function-
我正在尝试使用此功能使用bloomberg API加载数据-
' Make certain you have a Reference to C:\blp\API\ActiveX\blpdatax.dll
Sub FindBloombergData()
On Error GoTo Handler:
Dim oBlp As BLP_DATA_CTRLLib.BlpData
Dim ReqSecurities As Variant
Dim ReqFields As Variant
Dim vtResult As Variant
Dim n As Integer
Set oBlp = New BlpData
ReqSecurities = Array("SX5E Index")
ReqFields = Array("OPT_CHAIN")
With oBlp
.SubscriptionMode = ByRequest
.Subscribe ReqSecurities, 3, ReqFields, , , vtResult
End With
Stop 'and look at the results in Local or Watch Window
For n = 0 To UBound(vtResult(0, 0), 1)
Debug.Print n, vtResult(0, 0)(n, 0)
Next
Handler:
If Err.Number <> 0 Then
MsgBox Err.Description, vbCritical
End If
Set oBlp = Nothing
End Sub
However, whenever I try to run it I get this error: "compile-error user defined type not defined" What am I doing wrong? it highlights the line of code with this code: Dim oBlp As BLP_DATA_CTRLLib.BlpData
but I definitely have the bloomberg API installed
但是,每当我尝试运行它时,我都会收到此错误:“未定义编译错误用户定义类型”我做错了什么?它使用以下代码突出显示了代码行:Dim oBlp As BLP_DATA_CTRLLib.BlpData
但我绝对安装了bloomberg API
回答by iamchrisa
I just encountered the same problem. The reason is very simple. The legacy code was deprecated in 2011 and Bloomberg no longer supports it. The code needs to be converted to Bloomberg's COM V3 service.
我刚刚遇到了同样的问题。原因很简单。旧代码在 2011 年被弃用,彭博不再支持它。代码需要转换为Bloomberg的COM V3服务。