code to click and save files

rajrajsha

New Member
Joined
Apr 1, 2020
Messages
7
Office Version
  1. 365
Platform
  1. Windows
I need help with clicking a button using vba to download the files, Here are the steps what I'm trying to do:

Log in web site: (due to restriction i cant provide site details.)
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:

HTML:
<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">36</strong> Attachments
                </a>

All the attachments should be downloaded to specific folder with Order number as a folder name. Order numbers are listed in Column A of the Sheet1 (based on Order number we ill search the results)

I found this piece of code...
VBA Code:
Dim Dates As Object, Matters As Object, i As Long, Ws As Worksheet
     Dim L 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 WORKORDERS
         For L = 2 To Lr1
                     Set Ws = ActiveWorkbook.Sheets("Sheet2")
                     Set ie = New InternetExplorer
                     ie.navigate "https://www.abc.com/sc/wo/Work/index?id=" & _
                     ThisWorkbook.Sheets("Sheet1").Range("A" & L)
                     ie.Visible = True
                     Application.Wait Now + TimeValue("00:00:10")
                     Set Html = New MSHTML.HTMLDocument
                     Set Ws = ThisWorkbook.Worksheets("Sheet2")
                     Html.body.innerHTML = ie.document.querySelectorAll("..btn btn-default").Item(1).outerHTML     'Got stuck here


Any Help please.. Thanks
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.

Forum statistics

Threads
1,223,903
Messages
6,175,286
Members
452,631
Latest member
a_potato

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top