昏暗作为字典.编译错误:未定义用户定义的类型 [英] Dim As Dictionary. Compile Error: User-defined type not defined
问题描述
可以帮您解决这个问题吗? 每当我运行此宏时,它都会停在以下位置:
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.
此脚本的目的是使用excel对网站进行剩余调用,以便我可以下载历史数据.我目前停留在登录部分.
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.
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
推荐答案
添加对Microsoft脚本运行时的引用,如@ YowE3k所述:
Add a reference to Microsoft Scripting Runtime as @YowE3k said:
在VBA编辑器中:
工具->参考
查找Microsoft脚本运行时
Find Microsoft Scripting Runtime
检查
点击确定
这篇关于昏暗作为字典.编译错误:未定义用户定义的类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!