I am trying to automate the click on Excel icon action to download Excel data using VBA from the following link Financial Statement of a Firm
The below is a html code for that Excel icon
<div class="fri nav-item-right">
<a onclick="changPeriod(2);" class="red" id="hang_quy" style="cursor:pointer;">Hàng quý</a>"|"
<a onclick="changPeriod(1);" id="hang_nam" style="cursor:pointer;" class="">Hàng năm</a>
<span class="curp"><img src="/images/icon-excel.jpg" alt="#" id="divPoints"></span>
</div>The below VBA code intends to trigger the Excel icon clicking action.
URL = "http://finance.tvsi.com.vn/Enterprises/FinancialStatements?symbol=AAA" ' & Range("TickerName")
Set objIE = CreateObject("InternetExplorer.Application")
ThisWorkbook.Activate
objIE.Visible = True
objIE.navigate URL
Do While objIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
Set HTMLDoc = objIE.document
Set oHTML_Elements = HTMLDoc.getElementsByClassName("fri nav-item-right")
For Each oHTML_Element In oHTML_Elements
For Each oHTML_Element_Li In oHTML_Element.getElementsByTagName("span")
oHTML_Element_Li.Children(0).Click
Next
Next
Do While objIE.Busy
Application.Wait DateAdd("s", 1, Now)
Loop
objIE.Quit
What happened was the Web Element Tag Name "a" got clicked and not the Excel icon which belong to the Tag Name span.
What did I do wrong from the above code? and if possible please let me know your thoughts on getting this Excel icon Clicked.
Thank you for reading this post and I am looking forward to receiving your suggestion.
Best regards
BK
Aucun commentaire:
Enregistrer un commentaire