I have a Sub in an Excel workbook that accesses an API.
On the first run, a login modal pops up as if the Authorization header hadn't been sent.
If I close that without logging in and run the sub a second time, authorization is successful and my data is returned.
This only occurs the first time I open the workbook for the day. The authorization is successful the next time I open the workbook. As far as I can tell, my code is correct. Any suggestions?
Dim hReq As Object
Set hReq = CreateObject("MSXML2.XMLHTTP")
hReq.Open "GET", APIURL, False
hReq.setRequestHeader "Authorization", "BASIC " & Base64Encoding(APIKEY & ":xxx")
hReq.Send