Consulting

Results 1 to 4 of 4

Thread: Solved: Web browser control

  1. #1
    VBAX Regular
    Joined
    Nov 2006
    Posts
    41
    Location

    Solved: Web browser control

    Hello

    I've created a form and added the web browser control to it along with a command button. When the button is pressed, the browser is directed to a website. The website is then redirected (not every time) to a login page where the user must enter user name and password.

    It's very inconsistent. Usually once the user name and password are entered, I'm not redirected to login page.

    Is there a way to detect when the webpage is redirected so that I might be able to enter sendkeys function to automatically enter user name and password?

    Thanks.

    Croeg

  2. #2
    Yes. What is the url? Every webpage is unique and you will need to test for a url or some other document property to determine where you are at. I can help you if you can provide the URL. You might also consider checking for the associated cookie and know beforehand. This can be done by way of code without using sendkeys. Also the login can be done without sendkeys...

  3. #3
    VBAX Regular
    Joined
    Nov 2006
    Posts
    41
    Location

    RE Web browser control

    Hi tstom,

    Thanks for responding.

    I sent you a private message with the URL address.

    Thanks

    Croeg

  4. #4
    VBAX Regular
    Joined
    Nov 2006
    Posts
    41
    Location

    RE Web browser control

    tstom,

    Thanks so much for your help....this worked perfectly !!!!


    [VBA]
    Option Explicit
    Private Const UserName As String = "Some Username"
    Private Const PassWord As String = "Some Password"
    Private Attempts As Integer
    Private Sub CommandButton1_Click()
    WebBrowser1.Navigate "https://www.xxx.com"
    End Sub

    Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
    If TypeOf pDisp Is WebBrowser Then
    If InStr(pDisp.Document.Title, "Global Logon") <> 0 Then
    If Attempts < 3 Then
    pDisp.Document.all("userid").Value = UserName
    pDisp.Document.all("password").Value = PassWord
    pDisp.Document.all("btnSubmit").Click
    Attempts = Attempts + 1
    End If
    End If
    End If
    End Sub
    [/VBA]

    Croeg

Posting Permissions

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