Looping through internet explorer page to find a link

Hi, I'm looking for a method to search through all internet explorer pages to find "Update", how would i go about this. I already have the remainder of my project sorted, just this bit to find the link by the name of the link. Can't use ie.document.links(x).click as the link's position changes constantly.

Ta.
LVL 3
TOC-FriedAsked:
Who is Participating?
 
LostieConnect With a Mentor Commented:
How about a loop that checks every link to see if it's text is "Update", then clicks on that link?

For Each Link In IE.Document.Links
    If Trim$(Link.InnerText) = "Update" Then Link.Click
Next

If you're using VB6, you'll need to "Dim Link As Object" beforehand. To find the link by it's HREF instead of by it's text, replace Link.InnerText with Link.HREF. And if the link is in a frame other than the first frame, use something like "IE.Document.Frames(1).Document.Links".
There is of course more than 1 way of doing this, but without seeing the HTML source of your page, this is the best I could come up with. Hope it helps.
0
 
TOC-FriedAuthor Commented:
Thanks for that lostie, I'm more then sure your code was what i was looking for. I'll pass points after I test later today.

Thanks!
0
 
TOC-FriedAuthor Commented:
any ideas how to make my application wait 10 minutes or so before looping through a while event after it's completed? ie. just before wend i want it to wait 10 minutes??
0
 
LostieCommented:
Sure, put this line at the top of your form/module/class:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

and before the WEnd of your loop, just do:

Call Sleep(600000)
DoEvents

That'll 'pause' for 600,000 milliseconds (600 seconds, which is 10 minutes)...
0
 
TOC-FriedAuthor Commented:
Thanks again.. I did find another method as well, but yours seems a lot smaller and probably more efficient.
0
All Courses

From novice to tech pro — start learning today.