• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Download csv files from hyperlinks using vba

I have around 200 (indirect) hyperlinks when clicked excel asks for opening the csv file when OK, it open that csv file which I need to download. And when copy hyperlink to IE, it ask me to save or open that file.

The length of hyperlink is around 1000 char.
Please help me to download those files to one location.
 

Attachments

  • DownloadFrom_Url.xlsm
    9.8 KB · Views: 4
I have got below code but it needs to save file manually in downloads page:
Code:
Sub TESTING()
'Need to reference to Microsoft Internet Controls
    Dim URL As String
    Dim i As Long
    'URL = Worksheets("References & Resources").Range("URLMSL")
  ' URL = "http://www.mrexcel.com/board2/viewtopic.php?t=69685" 'for TEST
  ' i = 2
  For i = 2 To 192
  URL = Range("E" & i).Value
    Dim IE As Object
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    IE.Navigate URL
'    Do While IE.ReadyState <> 4
'        DoEvents
'    Loop
    SendKeys "%S"
    Next
    IE.ExecWB OLECMDID_SAVEAS, OLECMDEXECOPT_DODEFAULT    'SaveAs
   
End Sub
 
I could do this with powershell command as what I want like giving output name also:
Invoke powershell cmd and run following command once:
Code:
$client = new-object System.Net.WebClient
Then create commands like this in excel:
Code:
$client.DownloadFile(“Download Link”,“File Destination\file name.file extension”)
Paste them all, it's done!
 
Back
Top