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
  1. AutoLogonPolicy_Always = 0
  2. AutoLogonPolicy_Never = 2
  3. AutoLogonPolicy_OnlyIfBypassProxy = 1
WinHttpRequestOption
  1. WinHttpRequestOption_EnableCertificateRevocationCheck = 18
  2. WinHttpRequestOption_EnableHttp1_1 = 17
  3. WinHttpRequestOption_EnableHttpsToHttpRedirects = 12
  4. WinHttpRequestOption_EnablePassportAuthentication = 13
  5. WinHttpRequestOption_EnableRedirects = 6
  6. WinHttpRequestOption_EnableTracing = 10
  7. WinHttpRequestOption_EscapePercentInURL = 3
  8. WinHttpRequestOption_MaxAutomaticRedirects = 14
  9. WinHttpRequestOption_MaxResponseDrainSize = 16
  10. WinHttpRequestOption_MaxResponseHeaderSize = 15
  11. WinHttpRequestOption_RejectUserpwd = 19
  12. WinHttpRequestOption_RevertImpersonationOverSsl = 11
  13. WinHttpRequestOption_SecureProtocols = 9
  14. WinHttpRequestOption_SelectCertificate = 5
  15. WinHttpRequestOption_SslErrorIgnoreFlags = 4
  16. WinHttpRequestOption_URL = 1
  17. WinHttpRequestOption_URLCodePage = 2
  18. WinHttpRequestOption_UrlEscapeDisable = 7
  19. WinHttpRequestOption_UrlEscapeDisableQuery = 8
  20. WinHttpRequestOption_UserAgentString = 0
WinHttpRequestSecureProtocols
  1. SecureProtocol_ALL = 168
  2. SecureProtocol_SSL2 = 8
  3. SecureProtocol_SSL3 = 32
  4. SecureProtocol_TLS1 = 128
  5. SecureProtocol_TLS1_1 = 512
  6. SecureProtocol_TLS1_2 = 2048
WinHttpRequestSslErrorFlags
  1. SslErrorFlag_CertCNInvalid = 4096
  2. SslErrorFlag_CertDateInvalid = 8192
  3. SslErrorFlag_CertWrongUsage = 512
  4. SslErrorFlag_Ignore_All = 13056
  5. SslErrorFlag_UnknownCA = 256