chacanger
02-15-2011, 01:10 PM
Hi
The other day I asked if there was a way to search for text on an ie page without exporting it to Excel, to which I was told InStr would work, I know have another question which relates to the same thing but needs to do something else too, Is it possible to search for the text that is next to what you search for...
by this I mean if you had a web page that said... "My name is chacanger" and you wanted to search for the My name is part (as the name would change), then get it to tell you what was the text to the right of it, so it would produce an answer of "Chacanger"
Sub TextToRight()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
'####Search for Web Page####
ie.Navigate "http://www.google.co.uk/search?client=opera&rls=en&q=google&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest"
'####Loop until fully loaded####
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
FindText = InStr(1, ie.Document.body.innerhtml, "The local version")
MsgBox FindText
If FindText > 0 Then
'####Needs to find the text after the word version and place in MsgBox####
MsgBox "The text exists"
Else
MsgBox "The text dosen't exist"
End If
ie.Quit
Set ie = Nothing
End Sub
The text next to it can vary in size on my project but it stays within the same line.
Any suggestions would be greatly appreciated
The other day I asked if there was a way to search for text on an ie page without exporting it to Excel, to which I was told InStr would work, I know have another question which relates to the same thing but needs to do something else too, Is it possible to search for the text that is next to what you search for...
by this I mean if you had a web page that said... "My name is chacanger" and you wanted to search for the My name is part (as the name would change), then get it to tell you what was the text to the right of it, so it would produce an answer of "Chacanger"
Sub TextToRight()
Dim ie As InternetExplorer
Set ie = New InternetExplorer
'####Search for Web Page####
ie.Navigate "http://www.google.co.uk/search?client=opera&rls=en&q=google&sourceid=opera&ie=utf-8&oe=utf-8&channel=suggest"
'####Loop until fully loaded####
Do Until ie.ReadyState = READYSTATE_COMPLETE
Loop
FindText = InStr(1, ie.Document.body.innerhtml, "The local version")
MsgBox FindText
If FindText > 0 Then
'####Needs to find the text after the word version and place in MsgBox####
MsgBox "The text exists"
Else
MsgBox "The text dosen't exist"
End If
ie.Quit
Set ie = Nothing
End Sub
The text next to it can vary in size on my project but it stays within the same line.
Any suggestions would be greatly appreciated