I can't help thinking that
Excel VBA is not the best tool for the job when you probably already have a far more capable (and powerful) tool already built-in...
PowerShell.
At its simplest, the following one-liner run from a
PowerShell console may do it:
Code:
gc urls.txt | % {iwr $_ -outf $(split-path $_ -leaf)}
No, I didn't write it... have a look at
PowerShell: Download a list of files for an article about a basic way to feed in a text file of URLs and download them, including an expanded
PowerShell explanation of what that one-liner actually means.
Better still, have a look at this
Download a File with an Alternative PowerShell wget Command article which explores 4 different methods of doing the same and walks you through each of them. (NB: Make sure you read the comment about asynchronomous mode at the end of the article.)
In particular, have a look at the method using
BITS with a list of files.
BITS (Background Intelligent Transfer Service) is built-in to
Windows 10 and, unlike
Excel VBA, is a service
specifically designed to download files efficiently. All you have to do is use
PowerShell to tell it what to do and, again, it could be as simple as:
Code:
Import-Csv .\filelist.csv | Start-BitsTransfer
Having said that, once you realise the built-in capability of
PowerShell it shouldn't take all that much to adapt other people's code to your own situation (including error-checking and perhaps adding logging).
Just Google
powershell download list of files to find lots more articles, examples and explanations.
The point I'm trying to make is that, IMO,
PowerShell is MUCH better suited to carrying out this type of task. Use
Excel to create the
CSV file (and perhaps
VBA to merely run any
PowerShell script from within
Excel).
Hope this helps...