title: Using the Bloomberg API in vba
body: <p>I am trying to load data with the bloomberg API using this function-</p>
  
  <pre><code>' 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 &lt;&gt; 0 Then
  MsgBox Err.Description, vbCritical
  End If
  
  Set oBlp = Nothing
  End Sub
  </code></pre>
  
  <p>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: <code>Dim oBlp As BLP_DATA_CTRLLib.BlpData</code> but I definitely have the bloomberg API installed</p>