I am trying to wrote some code that will lookup a word in an excel cell, the search for that word and, most importantly, click on the link that returns.
I have the search part down, but it's the click on the link I'm struggling with. the HMTL extract is -
<span>
<div class="searchResult webResult ">
<div class="resultTitlePane">
<h3>
<a class="outbound" href="whatever" target ="" rel="nofollow" rev="lots of
text">..</a>
</h3>
</div>
I've not typed out the href and rel text, but I just want to be able to click the link that's returned and follow through to that site. Any help please?
this is my code -
Sub test()
Dim ie As InternetExplorer
Dim RegEx As RegExp, RegMatch As MatchCollection
Dim MyStr As String
Dim pDisp As Object
Dim dtStartTime As Date
Set ie = New InternetExplorer
Set RegEx = New RegExp
Dim iedoc As Object
SearchEng = "http://easysearch.org.uk/search/?s="
LastRow = Range("A1").End(xlDown).Row
Do Until i = LastRow + 1
SearchMe = Range("A" & i)
ie.Navigate SearchEng & SearchMe
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
MyStr = ie.document.body.innerText
Set RegMatch = RegEx.Execute(MyStr)
If RegMatch.Count > 0 Then
ie.Navigate RegMatch(0)
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
ie.Visible = True
Set iedoc = ie.document
''NEED TO ADD SOMETHING HERE TO CLICK LINK''
End If
i = i + 1
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
Loop
Set RegEx = Nothing
ie.Quit
Set ie = Nothing
End Sub