Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 73905

How do I click a SPAN element in Internet Exlorer using VBA

$
0
0

Im trying to click on a span element on a website I accesed with Username and Password, I´ve tried all the possible ways I can imagine(most of these found on this website). Maybe you can help me out, this is the code I´m using:

Sub internet_explore()

Dim ie As InternetExplorer
Dim page As HTMLDocument


Set ie = CreateObject("internetexplorer.application")
ie.Visible = True
ie.Navigate2 "TheWebPage"

Do While ie.readyState <> READYSTATE_COMPLETE 
DoEvents
Loop

'Here I enter code to do the login and make a search  by filling an input box and  clicking on search button

'wait for the search to load up
Do While ie.readyState <> READYSTATE_COMPLETE
DoEvents
Loop

Set page = ie.Document

Dim e as HTMLElementCollection
Dim c As HTMLButtonElement

For Each e In page.getElementsByTagName("span")
    If e.innerText = "10.180.9.1" Then  

      Set c = e
      c.click
      c.parentElement.click

   End If

Next

End Sub

This is what I search and the button I click: what I Search

The Result I get(Table) and why I need to click on that span element since i get many results: Results

<div class="x-grid3-cell-inner x-grid3-col-column7" style="CURSOR: pointer" unselectable="on"><span class="Grid-Panel-All">10.180.9.1<div>

Viewing all articles
Browse latest Browse all 73905

Trending Articles



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