以下代码从某个位置下载文件。它正在我的机器上工作,但不在服务器上。我得到了:
运行时错误3001:'.write xHttp.responseBody
'参数类型错误或超出可接受的范围...'
以下是代码段:
For i = 2 To row_cnt
Value1 = xlSheet.Cells(i, 1).Value
Value2 = xlSheet.Cells(i, 2).Value
'MsgBox "value of i--> " & i
Dim xHttp: Set xHttp = CreateObject("Microsoft.XMLHTTP")
Dim bStrm: Set bStrm = CreateObject("Adodb.Stream")
xHttp.Open "GET", Value1, False, "username", "password"
xHttp.Send
With bStrm
.Type = 1 '//binary
.Open
.write xHttp.responseBody
.savetofile Value2, 2 '//overwrite
End With