Results 1 to 2 of 2

Thread: [RESOLVED] Web Browser Control Next Page

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2008
    Posts
    15

    Resolved [RESOLVED] Web Browser Control Next Page

    Here is the code I have so far. It navigates to the page, enters the username and password and clicks the login button. Now on the next page I want it to search for a link and click that. How do I do that? Do I start a new sub? Right now it seems the _DocumentComplete sub just wants to cycle over and over again, do I enter the new code there? Static's Webpage has been a great help and I'm pretty sure I know how to code what I want the program to do, I just don't know where to put it. Any tips are appreciated. Thank you.

    One last thing, after you navigate to the initial web address the URL becomes dynamic, this is the reason for the StoredURL variable.

    Code:
    Public StoredURL As String
    Private Sub Form_Load()
        WebBrowser1.Navigate "http://www.URL.com"
    End Sub
    
    Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
        If (pDisp Is WebBrowser1.Application) Then
            StoredURL = URL
            Exit Sub
        End If
    End Sub
    
    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
        If (pDisp Is WebBrowser1.Application) Then
            If URL = StoredURL Then
                Dim HTML As HTMLDocument
                Set HTML = WebBrowser1.Document
                HTML.All.Item("UNTextbox").Value = "UserName"
                HTML.All.Item("PWTextbox").Value = "Password"
                HTML.All.Item("LoginButton").Click
            End If
        End If
    End Sub

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: Web Browser Control Next Page

    Everything can go in the _DocumentComplete event, even if it's a dozen pages you need to deal with. Just check the URL for each step or page you need to deal with. Set up more than one IF.....End If for the different URL's you need to be concerned about.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width