2017-09-09 132 views
2

您能否協助解決這個問題? 每當運行此宏,它停止在:Dim As Dictionary。編譯錯誤:用戶定義類型未定義

Dim authResult As Dictionary 

隨着的錯誤消息: 編譯錯誤:沒有定義用戶定義的類型。

我以前沒有使用字典類型,我試圖從示例宏中重新使用此代碼。

該腳本的目的是使用excel對網站進行其他調用,以便我可以下載歷史數據。我目前卡在登錄部分。

Sub Login() 

    Dim userName As String 
    Dim password As String 
    Dim apiKey As String 

    userName = "username" 
    password = "password" 
    apiKey = "key123" 

    'activityTextbox.Text = "" 
    'clearData 

    Dim authResult As Dictionary 
    Set authResult = restClient.authenticateAccount(userName, password, apiKey) 
    If Not authResult Is Nothing Then 
     'appendActivity "Connected" 
     ' Configure Excel to pull streaming updates as often as possible 
     Application.RTD.ThrottleInterval = 0 
     ' Uncomment for real-time prices - this is very CPU intensive 
     ' Buffer interval defaults to 500ms 
     'Application.WorksheetFunction.RTD "IG.api.excel.RTD.IGApiRTDServer", "", "bufferInterval", "0" 
     ' Set manual refresh to true from very remote locations 
     ' Application.WorksheetFunction.RTD "IG.api.excel.RTD.IGApiRTDServer", "", "manualRefresh", "true" 
     ' This will require manually calling refresh to update lighstreamer subscriptions, i.e. 
     ' Application.WorksheetFunction.RTD "IG.api.excel.RTD.IGApiRTDServer", "", "refresh" 
     Dim maxPriceRequestsPerSecond As Double 
     maxPriceRequestsPerSecond = 0 ' all available updates 
     If restClient.streamingAuthentication(maxPriceRequestsPerSecond) Then 
      m_loggedIn = True 
      'populateWatchlists 
      'populateAccounts 
      'manualStreamingRefresh 
     'Else 
     ' appendActivity "Lightstreamer connection failure" 
     End If 
    Else 
     MsgBox "Authentication failed" 
    End If 

End Sub 

在此先感謝。 乾杯, 喬

+0

搜索 「VBA字典」,你會找到解決辦法(或看看相關的)。 – BitAccesser

+4

在引用中包含「Microsoft Scripting Runtime」。 – YowE3K

回答

3

添加到Microsoft腳本運行時的引用,@ YowE3k說:

在VBA編輯:

工具 - >引用

AddRef1

查找Microsoft腳本運行時間

檢查它

點擊確定

AddRef2

相關問題