来自 VB excel 宏代码的错误 - msxml3.dll -2146697211 系统找不到指定的资源 [英] Error from VB excel macro code - msxml3.dll -2146697211 The system cannot locate the resource specified

查看:57
本文介绍了来自 VB excel 宏代码的错误 - msxml3.dll -2146697211 系统找不到指定的资源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 VB 宏 (excel) 中使用 MSXML.HTTPRequest 对象与 HTTP 服务器通信.问题是它间歇性地抛出以下错误.

I am using an MSXML.HTTPRequest object in a VB macro (excel) to communicate with an HTTP server. The problem is that it throws the following error intermittently.

msxml3.dll -2146697211 系统找不到资源指定.

msxml3.dll -2146697211 The system cannot locate the resource specified.

我在我的系统上注意到当网络出现故障时会发生这种情况,但我的客户抱怨它在他的机器上间歇性地发生.鉴于他的系统安装了 Windows 7 并且它有时可以工作,我认为这不是没有安装正确库的问题.他在几个网络上尝试过,但仍然失败.

I noticed on my system that this happened when the network was down, but my client has complained of it happening intermittently on his machine. Given that his system has Windows 7 installed and it is working at times, I don't think it is an issue of the correct library not being installed. He has tried it on a few networks, but it still fails.

Function xmlHTTPPost(strURL, strData)
    Dim objHttp

    On Error Resume Next
    xmlHTTPPost = ""
    Set objHttp = CreateObject("Microsoft.XMLHTTP")
    If Err.Number <> 0 Then
        Err.Clear
        Set objHttp = CreateObject("MSXML2.XMLHTTP")
    End If
    If Err.Number <> 0 Then
        MsgBox "Error creating XMLHTTP object"
        Err.Clear
        Exit Function
    End If
    objHttp.Open "GET", strURL, False
    If Err.Number <> 0 Then
        Err.Clear
        Set objHttp = Nothing
        Exit Function
    End If
    objHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
    objHttp.setRequestHeader "User-Agent", "Mozilla Compatible (MS IE 3.01 WinNT)"
    objHttp.Send
    If Err.Number <> 0 Then
        MsgBox "Error " & Hex(Err.number) & " sending to server:" & vbCrLf & Err.description
        xmlHTTPPost = "ERROR: " & Err.Source & " " & Err.Number & " " & Err.Description
        Err.Clear
    Else
        xmlHTTPPost = objHttp.responseText
    End If
    Set objHttp = Nothing
End Function

它在我的机器上完美运行,它是 Windows 7 + Microsoft Office 2007 安装.

It's working perfectly on my box, which is a Windows 7 + Microsoft Office 2007 installation.

我在网上查了很多,模糊的提到了两个原因.

I have searched a lot online, and two reasons have been vaguely mentioned.

  1. 由于代理或防火墙导致的网络问题.在这种情况下,它不应该连接,而不是断断续续地连接.
  2. 库安装问题.同样,它根本不应该起作用,但事实并非如此.

推荐答案

现在我可以通过将方法从 GET 更改为 POST 来解决这个问题.该错误是间歇性的,但幸运的是它开始出现在我的开发机器上一次,将 HTTP 方法更改为 POST 就成功了.虽然这应该发生很奇怪,但它奏效了.

For now I was able to solve this by changing the method from GET to POST. The error was intermittent but fortunately it started showing up on my dev machine once, and changing the HTTP method to POST did the trick. It's very odd that should happen though, but it worked.

这篇关于来自 VB excel 宏代码的错误 - msxml3.dll -2146697211 系统找不到指定的资源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆