I always use Application.FollowHyperlink
on VBA to launch the default web browser such as Microsoft Edge under Windows 10. I shall avoid Shell.Application or dll ShellExecute().
But now some usually accessed web site has added User-Agent control. If it's not set, the web server refuses my request with a
HTTP/1.1 403 Forbidden
response.
According to Microsoft,
Application.FollowHyperlink Address, SubAddress, NewWindow, AddHistory, ExtraInfo, Method, _
HeaderInfo
But I cannot send HeaderInfo, as I tried this:
Application.FollowHyperlink "https://www.example.com", "", false, false, "", 0, _
"User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36"
without any success.
VBA error messageBox popups
In English: Running error '8': cannot download requested data (Cannot Download the information you requested).
To prove the header problem,
curl
also failed without User-Agent header (error HTTP/1.1 403 Forbidden):
curl -I https://www.example.com
But it worked under Powershell console like this:
curl -I -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.182 Safari/537.36" https://www.example.com
What's the good syntax for HeaderInfo on VBA to send http User-Agent header to web server, any idea ?