我正在尝试使用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
然而,每当我试图运行它时,就会出现错误:"编译错误——用户定义的类型未定义"。我做错了什么?它用这段代码突出显示了代码行:
Dim oBlp As BLP_DATA_CTRLLib.BlpData
,但我肯定已经安装了Bloomberg API。