Forum Discussion
anupambit1797
Dec 02, 2024Iron Contributor
Downloading multiple files from excel hyperlinks
Dear experts, Could you please share any Excel formula or PQ solution to download multiple files from excel hyperlinks. Each cell have one hyperlink and there are total > 100 h...
Kidd_Ip
Dec 03, 2024MVP
How about this if VBA considered:
Sub DownloadFiles()
Dim ws As Worksheet
Dim cell As Range
Dim url As String
Dim http As Object
Dim fileName As String
Dim folderPath As String
' Set your folder path here
folderPath = "C:\Path\"
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change to your sheet name
For Each cell In ws.Range("A1:A100") ' Change the range to your hyperlink range
If cell.Hyperlinks.Count > 0 Then
url = cell.Hyperlinks(1).Address
Set http = CreateObject("MSXML2.XMLHTTP")
http.Open "GET", url, False
http.send
fileName = folderPath & Mid(url, InStrRev(url, "/") + 1)
If http.Status = 200 Then
With CreateObject("ADODB.Stream")
.Type = 1 ' adTypeBinary
.Open
.Write http.responseBody
.SaveToFile fileName, 2 ' adSaveCreateOverWrite
.Close
End With
End If
End If
Next cell
End Sub
- anupambit1797Dec 03, 2024Iron Contributor