昏暗的字典。编译错误:未定义用户定义的类型

时间:2022-11-06 18:54:20

Can you please assist with this problem? Whenever I run this macro, it stops at:

你能帮忙解决这个问题吗?每当我运行这个宏时,它停在:

Dim authResult As Dictionary

With an error message of: Compile error: User-defined type not defined.

出现以下错误消息:编译错误:未定义用户定义的类型。

I have not used the dictionary type before and I am trying to re-use this code from a sample macro.

我以前没有使用过字典类型,我试图从示例宏中重用这段代码。

The aim of this script is to use excel to make rest calls to a website so that I can download historic data. I am currently stuck at the login section.

此脚本的目的是使用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

Thanks in advance. Cheers, Joe

提前致谢。干杯,乔

1 个解决方案

#1


6  

Add a reference to Microsoft Scripting Runtime as @YowE3k said:

添加对Microsoft Scripting Runtime的引用为@ YowE3k说:

In the VBA Editor:

在VBA编辑器中:

Tools -> References

工具 - >参考

昏暗的字典。编译错误:未定义用户定义的类型

Find Microsoft Scripting Runtime

查找Microsoft Scripting Runtime

Check it

核实

Click okay

点击没关系

昏暗的字典。编译错误:未定义用户定义的类型

#1


6  

Add a reference to Microsoft Scripting Runtime as @YowE3k said:

添加对Microsoft Scripting Runtime的引用为@ YowE3k说:

In the VBA Editor:

在VBA编辑器中:

Tools -> References

工具 - >参考

昏暗的字典。编译错误:未定义用户定义的类型

Find Microsoft Scripting Runtime

查找Microsoft Scripting Runtime

Check it

核实

Click okay

点击没关系

昏暗的字典。编译错误:未定义用户定义的类型