Automatic download of browser content using Excel links and VBA



  • Hi Ranjith,

    Thanks for your kind help with the code earlier, though when I tried running it I am not sure it works correctly.

    Option Explicit
    Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
    (ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) As Long
    
    Sub downloadImages()
    Dim rng As Range, cell As Variant
    Set rng = Range(Range("A2"), Range("A10000").End(xlUp))
    For Each cell In rng
    URLDownloadToFile 0, cell.Offset(0, 1).Value, Application.ActiveWorkbook.Path & "\" & cell.Value, 0, 0
    Next
    End Sub
    

    Q: How do I specify the destination folder for the downloads please?

    Kindest Regards

    Tom


  • administrators

    Application.ActiveWorkbook.Path = Path of the active excel workbook.

    Replace it with full path of the your destination folder like - "C:\Users\Tom".

    You got to figure out few things on your own.



  • Thanks Ranjith,

    Clearly I am a total beginner here. What is the best place to start learning the whole coding thing you would recommend for guys like me?

    Best

    T


  • administrators

    If you want to learn VBA then you can start here - http://chandoo.org/wp/excel-vba/ which has a series of tutorials for beginners. I write only general How-Tos and advanced use cases of VBA so stay tuned to my blog for more practical use cases - https://codingislove.com/tag/vba/

    Hope that helps!



  • Of course it does! So did your code BTW - it worked like a charm! Loved it!

    Thank you so much for your kind help!

    Tom


guest-login-reply
 

reconnecting-message