Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88054

Save attachments from IE and save it in the specified folder

$
0
0

I need help with clicking a button using vba to download the files Here are the steps to what I'm trying to do: Log in web site: www.abc.com download attachments from the download attachments button. Save the files(all files - any format) to specified path with folder name as provided in Sheet1 of "A" column

This is the html code for the button:

<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>

All the attachments should be downloaded to specific folder with WO number as a folder names. WO number are listed in Column A of the Sheet1,

I wrote this piece of code to click the button

Sub AttachmentsAndNotes()


 Dim Dates As Object, Matters As Object, i As Long, Ws As Worksheet
 Dim L, Lr1, Lr As Long
 Dim Html As MSHTML.HTMLDocument

 Lr1 = ThisWorkbook.Sheets("Sheet1").Cells(Rows.Count, 1).End(xlUp).Row
 Dim ie As New InternetExplorer

    'SETTING IE FOR WO NUMBERS

     For L = 2 To Lr1
                 Set Ws = ActiveWorkbook.Sheets("Sheet2")
                 Set ie = New InternetExplorer
                 ie.navigate www.abc.com/sc/wo/index?id="& _
                 ThisWorkbook.Sheets("Sheet1").Range("A"& L)
                 ie.Visible = True
                 Application.Wait Now + TimeValue("00:00:05")
         Set Html = New MSHTML.HTMLDocument
                 Html.body.innerHTML = ie.document.querySelectorAll(".btn btn-default")

                 Set Dates = Html.querySelectorAll(".wo-attachments-link") <GOT ERROR HERE

Please find the attached image of attachments how they look in IE. enter image description here

Any help would be appreciated.


Viewing all articles
Browse latest Browse all 88054

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>