Hi,
I'm trying to download files from website and save all downloaded files into a folder.
Here are the steps to what I'm trying to do:
1. Log in web site (i don't have rights to provide URL) and download attachments from the download button. (I have mentioned HTML code for this button below) and save the files associated to this download button to specified path with folder name as provided in Sheet1 of "A" column ( this names will change according to the ID's mentioned in the A column).
Note: every time the download list/items may vary.. For example: it may contain 2 or 4 or 15 or some time only 1 attachment, even some time there are not attachements.
I've been trying using vba code mentioned below, but I have run into a problem. Currently, my script below opens the webpage and enters the values of cell A1 of Sheet1...
I have also attached HTML code below for your reference.
VBA Code
HTML Code goes here
Thanks in Advance.
I'm trying to download files from website and save all downloaded files into a folder.
Here are the steps to what I'm trying to do:
1. Log in web site (i don't have rights to provide URL) and download attachments from the download button. (I have mentioned HTML code for this button below) and save the files associated to this download button to specified path with folder name as provided in Sheet1 of "A" column ( this names will change according to the ID's mentioned in the A column).
Note: every time the download list/items may vary.. For example: it may contain 2 or 4 or 15 or some time only 1 attachment, even some time there are not attachements.
I've been trying using vba code mentioned below, but I have run into a problem. Currently, my script below opens the webpage and enters the values of cell A1 of Sheet1...
I have also attached HTML code below for your reference.
VBA Code
Code:
Sub DownloadAttach()
Dim IE As Object, doc As Object, hTable As Object, hBody As Object, hTR As Object
Dim hTD As Object, tb As Object, bb As Object, tr As Object, td As Object
Dim L As Long
Dim timet1 As Double
Dim y As Long, z As Long, wb As Excel.Workbook, ws As Excel.Worksheet
Lr1 = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
For L = 2 To Lr1
Set IE = New InternetExplorer
IE.navigate "https://www.abc.com/sc/wo/Workorders/index?id=" & ThisWorkbook.Sheets("Sheet1").Range("A" & L)
IE.Visible = True
Application.Wait Now + TimeValue("00:00:07")
Sheets("Sheet2").Select
Set doc = IE.document
Set hTable = doc.getElementsByClassName("row wo-download-attachments-link")
For Each tb In hTable
HTML:
<div class="row wo-download-attachments-link">
<a class="btn btn-default" href="#" data-bind="click : downloadAttachments, visible: $root.attachmentsViewModel.attachments().length > 0">
<i class="fa fa-download js-app-action-el" aria-hidden="true"></i>
Download <strong data-bind="text:$root.attachmentsViewModel.attachments().length">17</strong> Attachments
</a>
</div>
Thanks in Advance.
Last edited: