Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
VBA中的默认凭据_Vba_Proxy_Httpclient - Fatal编程技术网

VBA中的默认凭据

VBA中的默认凭据,vba,proxy,httpclient,Vba,Proxy,Httpclient,我正在尝试从VB向应用程序(VBA)发出HTTP请求 这应该很简单: URL = "https://www.google.com/" Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0") xhr.Open "GET", URL, False xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" xhr.Send MsgBox xhr.responseText

我正在尝试从VB向应用程序(VBA)发出HTTP请求 这应该很简单:

URL = "https://www.google.com/"
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "GET", URL, False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.Send
MsgBox xhr.responseText
但我支持一个需要基本身份验证(base64)的代理服务器

如何在VBA中设置凭据

(相当于:myHttpWebRequest.Credentials=CredentialCache.DefaultCredentials)

如果不可能,如何用另一种方法解决问题


谢谢

您需要setProxyCredentials方法。我没有要测试的代理,但这应该可以做到:

URL = "https://www.google.com/"
Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
xhr.Open "GET", URL, False
xhr.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
xhr.setProxy 2, "192.168.0.222:8080"
xhr.setProxyCredentials "your_username" , "password_for_username"
xhr.Send
MsgBox xhr.responseText

从中可以看出,2参数是您可能需要更改的版本号。

您可以将此VBScript改编为VBA:虽然有点晚,但这可能会有所帮助。如果代理使用登录用户,如果代理配置为internet explorer。