Hi Team,
Could you please advise me how to loop through the files in a sharepoint(Not network drive).
I found the below coding from Chandoo.Org website which works fine only if we give the complete path of the file.
but i want to loop through the files to download from the share point folder.
Kindly advise.
Code
Option Explicit
Sub DownloadXLFileFromURL()
Dim myURL As String, sFilename As String
myURL = "[URL]http://img.chandoo.org/hw/max-change-problem.xlsx[/URL]"
sFilename = Environ("SystemDrive") & Environ("HomePath") & _
Application.PathSeparator & "Desktop" & Application.PathSeparator & _
"file.xlsx"
Dim WinHttpReq As Object, oStream As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False ', "username", "password"
WinHttpReq.Send
myURL = WinHttpReq.ResponseBody
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile sFilename, 2 ' 1 = no overwrite, 2 = overwrite
oStream.Close
End If
End Sub
Display More
Thanks in advance for the help.
Regards,
Rahaman.