Web - Username, password and form submit

Rob_J

New Member
Joined
Apr 30, 2010
Messages
7
Hi,

First post here. Fairly new to VBA, I have a problem which I've searched this and other forums for an answer but none have quite got me to where I want to be. This goes beyond my trusty Mr Excel book...

The question.

How can I get my username and password into the form at the top of this web page - http://glenigan-cms.auros.co.uk/default.aspx and then submit.

The code that I've found enters my details but only in grey font. I belive this is because I have the wrong HTML id/name? I know even less about HTML than I do VBA!!

Should I be navigating to the form when I navigate to the page initially?


If I try to submit the form(0), it submits the search box?
I've tried changing the form number to 1,2,3,4 but this returns an error.


Code:
Sub Test()
    Set IE = CreateObject("InternetExplorer.application")
    IE.Visible = True
    IE.navigate ("[URL]http://glenigan-cms.auros.co.uk/default.aspx[/URL]")
 
    Do
        If IE.readyState = 4 Then
 
            Exit Do
        Else
            DoEvents
        End If
    Loop
 
    IE.document.forms(0).all("[COLOR=black]Template_GLE_Login_LoginView1_login_UserName").[/COLOR]Value = "theusername"
    IE.document.forms(0).all("Template_GLE_Login_LoginView1_login_Password").Value ="thepassword"
    IE.document.forms(0).submit
 
 
End Sub

I would be most grateful for a point in the right direction.

thank you,

Rob


this is the thread which has helped me thus far - http://www.mrexcel.com/forum/showthread.php?t=461524
Norie are you out there.....
 
Last edited:

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Try this:
Code:
Sub Test()

    Dim IE As Object

    Set IE = CreateObject("InternetExplorer.application")

    With IE
        .Visible = True
        .navigate ("http://glenigan-cms.auros.co.uk/default.aspx")

        While .Busy Or .readyState <> 4: DoEvents: Wend

        .document.all("Template_GLE_Login_LoginView1_login_UserName").Value = "YOURUSERNAME"
        .document.all("Template_GLE_Login_LoginView1_login_Password").Value = "YOURPASSWORD"
        .document.all("Template_GLE_Login_LoginView1_login_LoginButton").Click

        While .Busy Or .readyState <> 4: DoEvents: Wend
        Debug.Print .LocationURL
    End With

End Sub
 
Last edited:
Upvote 0
Thanks John,

You solved the problem with selecting the correct form.

Unfortunatly the values entered for the username and password are still grey and don't submit.

What seems to be changing is the "display text" but not actually entering any values in to the form?

Any other suggestions?

thanks,
Rob
 
Upvote 0
I don't think getElementById is the key because

.document.getElementById("Template_GLE_Login_LoginView1_login_UserName").Value

and

.document.all("Template_GLE_Login_LoginView1_login_UserName").Value

are just different ways of setting the value of the same element.

I think the .Focus is the important bit.

Code:
Sub Test2()

    Dim IE As Object

    Set IE = CreateObject("InternetExplorer.application")

    With IE
        .Visible = True
        .navigate ("http://glenigan-cms.auros.co.uk/default.aspx")

        While .Busy Or .readyState <> 4: DoEvents: Wend

        .document.all("Template_GLE_Login_LoginView1_login_UserName").Focus
        .document.all("Template_GLE_Login_LoginView1_login_UserName").Value = "YOURUSERNAME"
        .document.all("Template_GLE_Login_LoginView1_login_Password").Focus
        .document.all("Template_GLE_Login_LoginView1_login_Password").Value = "YOURPASSWORD"
        .document.all("Template_GLE_Login_LoginView1_login_LoginButton").Click

        While .Busy Or .readyState <> 4: DoEvents: Wend
        Debug.Print .LocationURL
    End With

End Sub
 
Upvote 0
John

Do you really need the Focus?

I ran your code without it and it appeared to work fine.:)
 
Upvote 0
I also thought my first code worked fine, notwithstanding the fact that I don't have a valid username and password and get an invalid login message when submitted. But then Rob J said "Unfortunatly the values entered for the username and password are still grey and don't submit." so I included the .Focus to match his solution in the other thread.
 
Upvote 0
John

When I stepped through the code with the Focus lines commented out it worked fine in putting the username and password.

However when the form was submitted I got the inevitable wrong username/password and the form kind of 'reset' itself.:)
 
Upvote 0

Forum statistics

Threads
1,223,246
Messages
6,170,996
Members
452,373
Latest member
TimReeks

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top