Filling in website UserName & Password with VBA

Big Lar

Well-known Member
Joined
May 19, 2002
Messages
557
I found this code (which I might find useful) to open Internet Explorer and fill in Username and password on the specified website.
It works until
ie.Document.getElementById("uid").Value = "testID"
. ("Object required" error)
I'm at a loss as to the correct nomenclature to try it out.

Also, can this or something else be modified to work with Microsoft Edge or Google Chrome?

Code:
Sub test()
' open IE, navigate to the desired page and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "app.groupworks.com/#/login"
 
    With ie
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
 
    End With
 
' Input the userid and password
  [COLOR=#008080]  ie.Document.getElementById("uid").Value = "testID"[/COLOR]
    ie.Document.getElementById("password").Value = "testPW"
 
' Click the "Search" button
    ie.Document.getElementById("enter").Click
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
End Sub
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Hi Big Lar,

I've changed the ElementId to "email", and added a part of code to click the sign in button.

Code:
Sub test()
' open IE, navigate to the desired page and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "app.groupworks.com/#/login"
 
    With ie
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
 
    End With
 
' Input the userid and password
    ie.document.getElementById("email").Value = "testID"
    ie.document.getElementById("password").Value = "testPW"
 
' click the sign in button
     Set tags = ie.document.getElementsByTagName("button")
        For Each tagx In tags
         If tagx.innerText = "Sign in" Then
         tagx.Click
        Exit For
    End If
Next
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
End Sub
 
Upvote 0
Wondering if anyone has a solution to my problem?
I know nothing about HTML(?) or Java script(?)

I'm attempting to use VBA to quickly login to a reservation site:

Code:
Sub test()
Private Sub CommandButton1_Click()
' open IE, navigate to the desired page and loop until fully loaded
    Set ie = CreateObject("InternetExplorer.Application")
    my_url = "https://denverpremier.ezlinksgolf.com/index.html#/login"
    
 
    With ie
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 400
        .Width = 400
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
 
    End With
 
' Input the userid and password
    ie.document.getElementById("Username").Value = "testID"
    ie.document.getElementById("password").Value = "testPW"
 
' click the sign in button
     Set tags = ie.document.getElementsByTagName("button")
        For Each tagx In tags
         If tagx.innerText = "Sign in" Then
         tagx.Click
        Exit For
    End If
Next
 
    Do Until Not ie.Busy And ie.readyState = 4
        DoEvents
    Loop
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,910
Messages
6,175,320
Members
452,635
Latest member
laura12345

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