Logging in via Automation

mario92

New Member
Joined
Oct 16, 2011
Messages
43
Office Version
  1. 365
Platform
  1. Windows
Hi

I've been trying for a while now and can't seem to get it. I think this would be easy for most of you


i want to automate logging into this website which include entering user/password and also clicking the login button.
I've tried the following and many other type variations of with no success

'ie.document.getElementsByClassName("small ValidatorHighlight").Value = "xxxxxxx" 'Find by class
ie.document.getElementsByid("ContenPlaceHolder1_Login1_txtLoginName").Value = "xxxxxxx" 'Find by id

anyone want to take a crack at it
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Can you post the rest of the code?
 
Upvote 0
Can you post the rest of the code?
Sub ClickIt()

Dim ie As New InternetExplorer
Dim doc As New HTMLDocument
Dim ecoll As Object

Set ie = New InternetExplorerMedium

ie.Visible = True
ie.navigate "First Trust"



Do
DoEvents
Loop Until ie.readyState = READYSTATE_COMPLETE


'''''''''''''''''''below is the part i can't figure out''''''''''''''''''''''''''''''''''''''''

'ie.document.getElementsByClassName("small ValidatorHighlight").Value = "mari92" 'Find by class
ie.document.getElementsByid("ContenPlaceHolder1_Login1_txtLoginName").Value = "mari92" 'Find by class
ie.document.getElementById("form1").Click

ie.document.getElementById("onsubmit").Click

End Sub
 
Upvote 0
This requires a reference to MS HTML Object Library.
VBA Code:
    Dim HTMLdoc As HTMLDocument
    Dim inputElem As HTMLInputElement

    Set HTMLdoc = IE.document
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_txtLoginName")
    inputElem.Value = "USER1234"
    
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_txtPassword")
    inputElem.Value = "PASSWORD1234"
            
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_btnLogin")
    inputElem.Click
 
Upvote 0
This requires a reference to MS HTML Object Library.
VBA Code:
    Dim HTMLdoc As HTMLDocument
    Dim inputElem As HTMLInputElement

    Set HTMLdoc = IE.document
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_txtLoginName")
    inputElem.Value = "USER1234"
   
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_txtPassword")
    inputElem.Value = "PASSWORD1234"
           
    Set inputElem = HTMLdoc.getElementById("ContentPlaceHolder1_Login1_btnLogin")
    inputElem.Click

thanks so much, it worked
 
Upvote 0

Forum statistics

Threads
1,214,854
Messages
6,121,941
Members
449,056
Latest member
denissimo

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