I'm writing a macro to autograb data from a list of websites and one of my websites makes use of a toolbar. To pull up the download button dialog, I need to click a button on the toolbar labeled "Download." The "Download" button I am supposed to click however is not an actual button and has no effect if not errors when I attempt to click it from VBA. I have also attempted to click each of the <spans> under the anchor class but nothing worked their either.
Below is the HTML for the "button" if you can call it that. I also have my code below which grabs an element by classname but clicking it accomplishes nothing.
HTML:
<div class-"tabToolbarButton tab-widget download" role="button"
data-tb-test-id="download-ToolbarButton" id="download-ToolbarButton" tabindex="-1"
style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Download">
<span class="tabToolbarButtonImg tab-icon-download"></span>
<span class="tabToolbarButtonText">Downloads</span>
VBA:
'Variables
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim DownloadButton As HTMLInputButtonElement
Set IE = New InternetExplorerMedium
With IE
.Visible = True
.Left = 25
.Top = 25
.Height = 700
.Width = 1300
AppActivate ("Internet Explorer")
.Navigate Site
IE_Wait IE
Set HTMLdoc = .Document
Application.Wait (Now + TimeValue("00:00:10"))
IE_Wait IE
Set DownloadButton = HTMLdoc.getElementsByClassName("tabToolbarButton tab-widget download")(0)
DownloadButton.Click '<-- ERRORS here as DownloadButton is not set to a real <button>
'CODE BELOW FINDS THE CORRECT BUTTON TO DOWNLOAD DATA
'NEED TO FIND DOWNLOAD BUTTON TO ENABLE VISIBLITY OF DIALOGBOX
Debug.Print HTMLdoc.getElementsByClassName("fppw03o low-density").Length
Site link has been omitted, and the IE_Wait function merely waits until the IE is done loading. IE_Wait absolutely works given I have used it multiple times for different pages. Application.Wait is merely used to ensure everything has loaded properly before running code.
Any help would be appreciated! Thank you
---
When hovering over the button, the top class changes to
<div class="tabToolbarButton tab-widget download hover"...<div>
Same with when it is clicked, it changes to
<div class="tabToolbarButton tab-widget download hover focus"...<div>
momentarily.
Nothing happens with:
ie.document.querySelector(".tab-icon-download + .tabToolbarButtonText").click
I attempted to click each of those elements, the anchor, .tab-icon-download, and both spans, but nothing would actually get clicked.
---
[List of all <div> Event Listeners][1] for the parent <div>. No onclick event to be seen and I am unsure how the <div> is even watched. .Focus in VBA errors out and I am stumped.
[1]:
Below is the HTML for the "button" if you can call it that. I also have my code below which grabs an element by classname but clicking it accomplishes nothing.
HTML:
<div class-"tabToolbarButton tab-widget download" role="button"
data-tb-test-id="download-ToolbarButton" id="download-ToolbarButton" tabindex="-1"
style="user-select: none; -webkit-tap-highlight-color: transparent;" title="Download">
<span class="tabToolbarButtonImg tab-icon-download"></span>
<span class="tabToolbarButtonText">Downloads</span>
VBA:
'Variables
Dim IE As InternetExplorer
Dim HTMLdoc As HTMLDocument
Dim DownloadButton As HTMLInputButtonElement
Set IE = New InternetExplorerMedium
With IE
.Visible = True
.Left = 25
.Top = 25
.Height = 700
.Width = 1300
AppActivate ("Internet Explorer")
.Navigate Site
IE_Wait IE
Set HTMLdoc = .Document
Application.Wait (Now + TimeValue("00:00:10"))
IE_Wait IE
Set DownloadButton = HTMLdoc.getElementsByClassName("tabToolbarButton tab-widget download")(0)
DownloadButton.Click '<-- ERRORS here as DownloadButton is not set to a real <button>
'CODE BELOW FINDS THE CORRECT BUTTON TO DOWNLOAD DATA
'NEED TO FIND DOWNLOAD BUTTON TO ENABLE VISIBLITY OF DIALOGBOX
Debug.Print HTMLdoc.getElementsByClassName("fppw03o low-density").Length
Site link has been omitted, and the IE_Wait function merely waits until the IE is done loading. IE_Wait absolutely works given I have used it multiple times for different pages. Application.Wait is merely used to ensure everything has loaded properly before running code.
Any help would be appreciated! Thank you
---
When hovering over the button, the top class changes to
<div class="tabToolbarButton tab-widget download hover"...<div>
Same with when it is clicked, it changes to
<div class="tabToolbarButton tab-widget download hover focus"...<div>
momentarily.
Nothing happens with:
ie.document.querySelector(".tab-icon-download + .tabToolbarButtonText").click
I attempted to click each of those elements, the anchor, .tab-icon-download, and both spans, but nothing would actually get clicked.
---
[List of all <div> Event Listeners][1] for the parent <div>. No onclick event to be seen and I am unsure how the <div> is even watched. .Focus in VBA errors out and I am stumped.
[1]: