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

查看:893
本文介绍了来自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天全站免登陆