VBA Microsoft WinHTTP Services Library
The WinHTTP Services Library can be used to send HTTP requests using the WinHTTPRequest class.
Public Sub Example()
Dim URL As String
URL = "https://www.bing.com/"
Dim Req As Object 'WinHttp.WinHttpRequest
Set Req = CreateObject("WinHttp.WinHttpRequest.5.1")
With Req
.Open "GET", URL, False
.Send
Debug.Print "Response Headers:"
Debug.Print .getAllResponseHeaders
Debug.Print "Response Text:"
Debug.Print .responseText
End With
Set Req = Nothing
End Sub
Classes
Class | Description |
---|---|
WinHttpRequest | Used for sending HTTP requests. |
Enums and Consts
WinHttpRequestAutoLogonPolicy
- AutoLogonPolicy_Always = 0
- AutoLogonPolicy_Never = 2
- AutoLogonPolicy_OnlyIfBypassProxy = 1
WinHttpRequestOption
- WinHttpRequestOption_EnableCertificateRevocationCheck = 18
- WinHttpRequestOption_EnableHttp1_1 = 17
- WinHttpRequestOption_EnableHttpsToHttpRedirects = 12
- WinHttpRequestOption_EnablePassportAuthentication = 13
- WinHttpRequestOption_EnableRedirects = 6
- WinHttpRequestOption_EnableTracing = 10
- WinHttpRequestOption_EscapePercentInURL = 3
- WinHttpRequestOption_MaxAutomaticRedirects = 14
- WinHttpRequestOption_MaxResponseDrainSize = 16
- WinHttpRequestOption_MaxResponseHeaderSize = 15
- WinHttpRequestOption_RejectUserpwd = 19
- WinHttpRequestOption_RevertImpersonationOverSsl = 11
- WinHttpRequestOption_SecureProtocols = 9
- WinHttpRequestOption_SelectCertificate = 5
- WinHttpRequestOption_SslErrorIgnoreFlags = 4
- WinHttpRequestOption_URL = 1
- WinHttpRequestOption_URLCodePage = 2
- WinHttpRequestOption_UrlEscapeDisable = 7
- WinHttpRequestOption_UrlEscapeDisableQuery = 8
- WinHttpRequestOption_UserAgentString = 0
WinHttpRequestSecureProtocols
- SecureProtocol_ALL = 168
- SecureProtocol_SSL2 = 8
- SecureProtocol_SSL3 = 32
- SecureProtocol_TLS1 = 128
- SecureProtocol_TLS1_1 = 512
- SecureProtocol_TLS1_2 = 2048
WinHttpRequestSslErrorFlags
- SslErrorFlag_CertCNInvalid = 4096
- SslErrorFlag_CertDateInvalid = 8192
- SslErrorFlag_CertWrongUsage = 512
- SslErrorFlag_Ignore_All = 13056
- SslErrorFlag_UnknownCA = 256