Erro do código de macro do Excel VB - msxml3.dll -2146697211 O sistema não pode localizar o recurso especificado
Eu estou usando um objeto MSXML.HTTPRequest em uma macro VB (excel) para se comunicar com um servidor HTTP. O problema é que ele lança o seguinte erro de forma intermitente.
msxml3.dll -2146697211 O sistema não pode localizar o recurso especificado.
Percebi no meu sistema que isso aconteceu quando a rede estava inoperante, mas meu cliente se queixou de que isso acontecia intermitentemente em sua máquina. Dado que seu sistema tem o Windows 7 instalado e está funcionando às vezes, não acho que seja um problema da biblioteca correta não estar instalada. Ele tentou em algumas redes, mas ainda falha.
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
Está funcionando perfeitamente na minha caixa, que é uma instalação do Windows 7 + Microsoft Office 2007.
Eu pesquisei muito online, e duas razões foram vagamente mencionadas.
Problemas de rede devido a proxy ou firewall. Neste caso, nunca deve ligar, não intermitentemente.Problema de instalação da biblioteca. Mais uma vez, não deve funcionar, mas não é esse o caso.Eu realmente aprecio qualquer ajuda sobre isso.