I am trying to download a file from SharePoint with VBA.
The file is a picture but the picture isn't view-able once it gets onto the system.
I think that I'm downloading it in the wrong format.
Sub DownloadFromSharepoint()
Dim myURL As String
myURL = "https://MYSHAREPOINTSITE"
Dim WinHttpReq As Object
Set WinHttpReq = CreateObject("Microsoft.XMLHTTP")
WinHttpReq.Open "GET", myURL, False
WinHttpReq.Send
If WinHttpReq.Status = 200 Then
Set oStream = CreateObject("ADODB.Stream")
oStream.Open
oStream.Type = 1
oStream.Write WinHttpReq.ResponseBody
oStream.SaveToFile ("C:UsersDOMAINemp.jpg")
oStream.Close
End If
End Sub
See Question&Answers more detail:os