我收到了此代码。...到达代码HttpReq.send时,我遇到了权限错误。
有趣的是,并非所有URL都出现权限错误问题,只有某些URL来自特定供应商。
我可以在同一台计算机上的浏览器中手动发送URL,没有任何问题。
Sub downloadIcalFiles(icalfilename)
Dim myURL As String
Dim HttpReq As Object
myURL = icalfilename
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
Set oStrm = CreateObject("ADODB.Stream")
oStrm.Open
oStrm.Type = 1
oStrm.Write HttpReq.responseBody
oStrm.SaveToFile "C:\Temp\ical" & "\" & "icalfile.csv", 2 ' 1 = no overwrite, 2 = overwrite
oStrm.Close
End If
End Sub