|
各位老师,我用WinHttpReq下载WEB远程文件,文件能够下载,但如果修改远程文件再用该方法下载的却是未修改前的,请问要如何解决呢?谢谢指教!!!
以下是我的下载代码
Sub cc()
Dim myURL As String, hzzh
myURL = "xxxx"'web远程文件地址
charToFind = "/"
hzzh = InStrRev(myURL, charToFind)
myURL = Left(myURL, hzzh) & WorksheetFunction.EncodeURL(Right(myURL, Len(myURL) - hzzh))
Sheet1.Range("a2") = myURL
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
WinHttpReq.send
Dim oStream As Object
Set oStream = CreateObject("ADODB.Stream")
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.responseBody
oStream.SaveToFile ThisWorkbook.Path & "\考勤管理系统.xlsm", 2 ' 1 = no overwrite, 2 = overwrite
oStream.Close
End If
Set WinHttpReq = Nothing
Set oStream = Nothing
End Sub
|
|