+ Reply to Thread
Results 1 to 2 of 2

Need help to device macro to download files using links in a table

  1. #1
    Registered User
    Join Date
    12-23-2020
    Location
    delhi, india
    MS-Off Ver
    2016
    Posts
    1

    Need help to device macro to download files using links in a table

    Hello forum members,

    I am on a lookout to download some files for a table of links. Table is 1 Column X 13 rows

    I need vba to catch hold of each row, copy its contents & download the files from links.

    I did collect codes from various places. The block for downloading the content has worked for me in my earlier project.

    But I don't get how to marry it with table looping................request forum members to help me correct the code.

    Below is the code to best of my understanding.

    Thanks a lot in advance for the support



    Sub download_files()

    Dim tbl As ListObject
    Dim x As Long
    Dim myURL As String

    Set tbl = ActiveSheet.ListObjects("derivatives_links")

    'Loop Through Every Row in Table
    For x = 1 To tbl.Range.Rows.Count

    myURL = "cell.Value"

    Dim HttpReq As Object
    Set HttpReq = CreateObject("Microsoft.XMLHTTP")
    With HttpReq

    .Open "GET", myURL1, False, "username", "password"
    .setRequestHeader "If-Modified-Since", "Sat, 1 Jan 2000 00:00:00 GMT"
    .send

    Debug.Print StrConv(.responseBody, vbUnicode)

    If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile ThisWorkbook.Path & "\derivatives_records, 2 ' 1 = no overwrite, 2 = overwrite"
    oStrm.Close

    End If

    End With

    Next x

    End Sub

  2. #2
    Forum Expert dangelor's Avatar
    Join Date
    09-06-2011
    Location
    Indiana, USA
    MS-Off Ver
    365 Pro Plus
    Posts
    2,274

    Re: Need help to device macro to download files using links in a table

    Possibly adapting this into your code...
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Links To Files From Within A Pivot Table
    By Atlantis101 in forum Excel Charting & Pivots
    Replies: 0
    Last Post: 02-09-2021, 01:49 PM
  2. How to download links in columns & name files with script
    By pdoyon in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-10-2018, 11:54 PM
  3. Macro to download PDF files from a list of URL's
    By anrichards22 in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 02-23-2016, 06:00 AM
  4. Replies: 32
    Last Post: 07-23-2013, 01:14 AM
  5. How to download files from FTP via excel macro
    By donyc in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-14-2011, 02:20 PM
  6. [SOLVED] loop through a list of links and download files.
    By abhay_547 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 11-06-2010, 03:40 PM
  7. [SOLVED] i want to download tif files one after the other links in excel
    By cncmac in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-09-2006, 01:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1