Looping through internet explorer page to find a link

Posted on 2005-04-12
Last Modified: 2010-05-02
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.

Question by:TOC-Fried
    LVL 1

    Accepted Solution

    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

    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.
    LVL 3

    Author Comment

    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.

    LVL 3

    Author Comment

    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??
    LVL 1

    Expert Comment

    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)

    That'll 'pause' for 600,000 milliseconds (600 seconds, which is 10 minutes)...
    LVL 3

    Author Comment

    Thanks again.. I did find another method as well, but yours seems a lot smaller and probably more efficient.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now