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




Reply With Quote