Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 22 of 22

Thread: VBA to Download documents using URLs & Save As to folder

  1. #21
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    It is best to avoid overwrite or not dialogs.
    e.g.
    1. Create a temporary folder.
    2. SaveAs to that folder.
    3. Copy temp folder files to master folder with no prompts but overwrite if they exist.

    (2) is where you do your SendKeys() thing. If your note your keyboard presses, no mouse clicks allowed, then SendKeys() can take those actions. Sounds like you know that part.

    If you need help with (1) or (2), please post back.

    Once you get it working, we can probably skip the IE object. For that kind of thing, we could probably use the sheetfollowhyperlink event:
    Private Sub Workbook_SheetFollowHyperlink(ByVal Sh As Object, ByVal Target As Hyperlink)
    Tip: To paste code, do so between code tags. Click the # icon on reply toolbar to insert the code tags easily.

  2. #22
    Hi team, can someone help me in this scenario to download files to multiple folders.
    Like in the below code how do i change pth for every specific file to specific folder.
    Ex: i want to move few files to "OLD" folder, and some files to "NEW" folder some of them to "MODERN" folder.. how can i loop the path as well. Thanks


    Sub DownloadFile()
    pth = "C:\VBAX"
    For Each link In ActiveSheet.Hyperlinks
    fname = Split(link.Address, "/")(UBound(Split(link.Address, "/")))
    filename = pth & fname
    URLDownloadToFile 0, link.Address, filename, 0, 0
    Next link
    End
    End Sub

Posting Permissions

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