Excel VBA出现奇怪的XML映射运行时错误

Excel VBA出现奇怪的XML映射运行时错误,xml,excel,vba,data-binding,Xml,Excel,Vba,Data Binding,Excel VBA中的XML映射在将值输入特定单元格后自动查询API并检索其数据时遇到问题。映射正常工作,刷新XML映射并将查询数据检索到另一个所需的单元格中,但尽管如此,它仍然在VBA中强制执行运行时错误 给定的运行时错误为“-2147217376(80041020)” '下载指定资源失败。' 这是我在VBA中的代码。我已经更改了网站的示例,但是查询的格式是相同的 If Target.Column = 6 And (Target.Row >= 1 And Target.Row <=

Excel VBA中的XML映射在将值输入特定单元格后自动查询API并检索其数据时遇到问题。映射正常工作,刷新XML映射并将查询数据检索到另一个所需的单元格中,但尽管如此,它仍然在VBA中强制执行运行时错误

给定的运行时错误为“-2147217376(80041020)”

'下载指定资源失败。'

这是我在VBA中的代码。我已经更改了网站的示例,但是查询的格式是相同的

If Target.Column = 6 And (Target.Row >= 1 And Target.Row <= 10000) Then
Dim CellVariable As String: CellVariable = Target.Value

End If

Dim Map As XmlMap
Set Map = ActiveWorkbook.XmlMaps(1)
Map.DataBinding.LoadSettings "http://example.website.com/api/question?name=" & CellVariable & "&api_key=xxxxxxxxx&format=xml"
On Error Resume Next
Map.DataBinding.Refresh
On Error Resume Next
如果Target.Column=6且(Target.Row>=1且Target.Row尝试更改

Map.DataBinding.LoadSettings "http://example.website.com/api/question?name=" & CellVariable & "&api_key=xxxxxxxxx&format=xml"
除此之外(添加括号):

或使用此(不同的方法):


我发现Excel无法登录网页时出现此错误。我找到的唯一解决方案是浏览到Internet Explorer中的位置,输入我的凭据,并告诉Internet Explorer记住我的登录名。
这将持续一段时间,直到Cookie过期或我再次登录。

哪一行抛出错误?Map.DataBinding.Refresh?抱歉,不,这是调试错误时的
Map.DataBinding.LoadSettings
行感谢您的建议-第一行仍然生成相同的运行时错误,第二行生成“运行时错误”错误9'(子脚本超出范围)错误,但很遗憾
Map.DataBinding.LoadSettings("http://example.website.com/api/question?name=" & CellVariable & "&api_key=xxxxxxxxx&format=xml")
urlstr = "http://example.website.com/api/question?name=" & CellVariable & "&api_key=xxxxxxxxx&format=xml"
ThisWorkbook.XmlMaps(Map).Import urlStr