How do I programatically scroll down on a webpage inside the MS Web Control?

Posted on 2006-04-10
Last Modified: 2010-08-05
I have the MS Web browser control on a form.
I have it load a page that is longer than the viewing area.
How can I code so that the page will automatically slowly scroll down to the end while it is being viewd?
(speed variable please)
Question by:yyuubum2
    LVL 85

    Accepted Solution

    Experiment with...

    Option Explicit

    Private Sub Form_Load()
        Timer1.Enabled = False
        Timer1.Interval = 250
        WebBrowser1.Navigate ""
    End Sub

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        Timer1.Enabled = True
    End Sub

    Private Sub Timer1_Timer()
        If WebBrowser1.Document.body.scrollTop < WebBrowser1.Document.body.scrollheight Then
            WebBrowser1.Document.parentWindow.scrollTo 0, WebBrowser1.Document.body.scrollTop + 1
            Timer1.Enabled = False
        End If
    End Sub

    Author Comment

    Idle Mind:
    You've done it...just one more tweek for more points?
    Can you include a test to see if the page has scrolled to the end or the max on the scrollbar?
    In otherwords, when its finished?

    LVL 85

    Expert Comment

    by:Mike Tomlinson
    I couldn't find any obvious ways to figure out if I'd reached the ~end~.

    I'll keep digging...

    Author Comment

    still hoping you can help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
    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…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    759 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

    9 Experts available now in Live!

    Get 1:1 Help Now