I am writing a code in Excel VBA to get href value of a class and navigate to that href link (i.e) here is the href value I want to get into my particular Excel sheet and I want to navigate to that link automatically through my VBA code.
<a href="/questions/51509457/how-to-make-the-word-invisible-when-its-checked-without-js" class="question-hyperlink">How to make the word invisible when it's checked without js</a> The result I'm getting is that I'm able to get that containing tag's class value How to make the word invisible when it's checked without js <---- this is title is what I am getting in my sheet. What I want to get is this title's holding a href link /questions/51509457/how-to-make-the-word-invisible-when-its-checked-without-js this is what I want to get and navigate through my code.
Please help me out. Thanks in advance
Below are the entire coding:
Sub useClassnames() Dim element As IHTMLElement Dim elements As IHTMLElementCollection Dim ie As InternetExplorer Dim html As HTMLDocument 'open Internet Explorer in memory, and go to website Set ie = New InternetExplorer ie.Visible = True ie.navigate "https://stackoverflow.com/questions" 'Wait until IE has loaded the web page Do While ie.readyState <> READYSTATE_COMPLETE DoEvents Loop Set html = ie.document Set elements = html.getElementsByClassName("question-hyperlink") Dim count As Long Dim erow As Long count = 0 For Each element In elements If element.className = "question-hyperlink" Then erow = Sheets("Exec").Cells(Rows.count, 1).End(xlUp).Offset(1, 0).Row Sheets("Exec").Cells(erow, 1) = html.getElementsByClassName("question-hyperlink")(count).innerText count = count + 1 End If Next element Range("H10").Select End Sub I cant find any answer in this website asked by anyone. Please don't suggest this question as duplicate.
<div class="row hoverSensitive"> <div class="column summary-column summary-column-icon-compact "> <img src="images/app/run32.png" alt="" width="32" height="32"> </div> <div class="column summary-column "> <div class="summary-title summary-title-compact text-ppp"> <a href="**index.php?/runs/view/7552**">MMDA</a> </div> <div class="summary-description-compact text-secondary text-ppp"> By on 7/9/2018 </div> </div> <div class="column summary-column summary-column-bar "> <div class="table"> <div class="column"> <div class="chart-bar "> <div class="chart-bar-custom link-tooltip" tooltip-position="left" style="background: #4dba0f; width: 125px" tooltip-text="100% Passed (11/11 tests)"></div> </div> </div> <div class="column chart-bar-percent chart-bar-percent-compact"> 100%'