Question

I had managed to write a short script that navigates to the link i desire but im unable to search a string "Hello World" in that webpage [please note that im not any expert in VBS and if there are any mistakes just forgive] and i dont know to the url where "Hello World" leads too.

On error resume next

Dim WshShell, objIE, ElementCol
Dim LinkHref
Dim a

LinkHref = "www.abcdef.com"

Set WshShell = WScript.CreateObject("WScript.Shell")

Set objIE = CreateObject("InternetExplorer.Application")

objIE.Visible = False    
objIE.Navigate LinkHref 

wshShell.AppActivate objIE

Do While objIE.Busy
   wscript.sleep 6000
Loop

LinkHref = "Hello World"

For Each a In objIE.Document.GetElementsByTagName("A")
  If LCase(a.GetAttribute("href")) = LCase(LinkHref) Then
    a.Click
    Exit For  
  End If
Next

objIE.Visible = True

No correct solution

OTHER TIPS

Try something like this

For Each a In objIE.Document.GetElementsByTagName("a")
  If LCase(a.href = LCase(LinkHref) Then
    a.Click
    Exit For  
  End If
Next
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top