2012-01-04 195 views
4

我想使用這個功能 -使用在VBA彭博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 

但是加載與彭博API數據,每當我嘗試運行它,我得到這個錯誤:「編譯錯誤的用戶定義類型沒有定義「我做錯了什麼?它突出顯示了這段代碼的代碼行:Dim oBlp As BLP_DATA_CTRLLib.BlpData但我絕對已經安裝了bloomberg API

+2

*確定你有一個參考... *你做了這個?工具 - >參考資料,找到彭博資訊庫並勾選它。 – 2012-01-04 15:56:36

+0

我有一個參考,仍然是相同的問題 – ecbtln 2012-01-05 16:10:26

+0

檢查對象瀏覽器(F2)的BLP_DATA_CTRLLib和它的BlpData,它們是否存在? – 2012-01-05 16:19:19

回答

2

我剛剛遇到了同樣的問題。原因很簡單。舊版代碼在2011年已被棄用,彭博不再支持。該代碼需要轉換爲彭博的COM V3服務。