Excel vba中的HttpReq.send提供权限错误

时间:2019-02-09 11:05:00

标签: excel vba

我收到了此代码。...到达代码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

0 个答案:

没有答案