Automatically configure VBA Proxy for HTTP requests

I need to create a client for web api in VBA, and it needs to work as a proxy (with authentication). I was looking at the WinHttp.WinHttpRequest and MSXML2.XMLHTTP / ServerXMLHTTP classes. It turns out that:

  • XMLHTTP automatically detects proxy settings provided through the proxy.pac file (good)
  • WinHttpRequest not (bad)

However, on the other hand:

Since I would like to have my pie and eat it, is there a way to get the proxy automatically configured for a component like WinHttpRequest that does not follow blind redirects?

+1
source share
1 answer

The VBA-Web project can help you solve a food problem.

https://github.com/VBA-tools/VBA-Web

I think you want to do something like:

Dim client As New WebClient
With client
    .BaseUrl = "https://www.google.com"
    .ProxyUsername = <user>
    .ProxyPassword = <password>
    .EnableAutoProxy = True
End With

Dim request As New WebRequest
With request
    .Method = WebMethod.HttpGet
    .Format = WebFormat.PlainText
End With

Dim response As WebResponse
Set response = client.Execute(request)
+3
source

All Articles