• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Automatic Login to Website

Ranjith kumar

New Member
Hello Excel ninjas,
I'm trying to login to a website automatically in chrome using VBA, I'm able to open the website but unable to enter login details, Please help me..Here is the code :


Code:
Sub AutoLoginChrome()
Dim HTMLDoc As HTMLDocument
Dim MyBrowser As WebBrowser
Dim MyHTML_Element As IHTMLElement
Dim chromePath As String
On Error GoTo Err_Clear
MyURL = "https://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html"
Set MyBrowser = New WebBrowser
MyBrowser.Silent = True
chromePath = "C:\Program Files\Google\Chrome\Application\chrome.exe"
Shell (chromePath & " -url https://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html")
[IMG]https://mail.google.com/mail/ca/u/0/images/cleardot.gif[/IMG]
MyBrowser.Visible = True
Do
Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
Set HTMLDoc = MyBrowser.document
HTMLDoc.all.Login_userName.Value = "......."
HTMLDoc.all.Login_password.Value = "........."
HTMLDoc.all.dateField.Value = "......"
For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
Next
Err_Clear:
If Err <> 0 Then
Err.Clear
Resume Next
End If
End Sub
 
Last edited by a moderator:
Hi, Ranjith kumar!

As a new user you might want to (I'd say should and must) read this:
http://chandoo.org/forum/forums/new-users-please-start-here.14/

And regarding your issue, as you didn't provide the proper log in components (Id, pwd, and DOB) -which you shouldn't do- we're unable to test it thoroughly, so you'll aid people who might read this describing what are you getting (displayed or in other form) when you debug the procedure step by step.

Another thing that you should confirm is if it works with IE (and what version) instead of with Chrome.

In the meanwhile this is what Google says:
https://www.google.com.ar/search?q=excel+vba+login+to+website+with+id+and+password
The 1st links are from highly reputed Excel sites, so if I were you I'd give it a try.

Regards!

PS: Whenever you post code, you should embed it within proper tags to preserve indentation and spacing, as it's displayed just above the reply text box in this page used for posting comments. Or using the related icon from the ribbon toolbar, 5th from th right excluding the last and separated one.
 
Hello JB7,
Thanks for your time, I tested it with IE and it is working there..I couldn't give login components because it is related to Income tax which should be confidential.
I will try some other ways to solve this issue, but if you could help with this, You are always welcome.
Regards,
Ranjith
 
Hi, Ranjith kumar!

You must not give the login information, never. But in this cases like this we're not able to test the whole process unless you provide another URL with login required but without security issues that would let us complete all the required steps (it might be the same URL with dummy/test login info, a mirrored server for testing, any other website with ID and password that can be given freely and then deleted or changed,...). Otherwise your solution will depend on each reader availability of such kinda sites.

Regards!
 
Hello JB7,
When i run this code, It doesn't even enter the login details into the concerned fields.
First i would to like to make the code which enters the data into the fields, whether it logins or not is secondary.
 
Hi, Ranjith kumar!
I neither have an analogue website URL nor the test login information to debug and check it.
Regards!
 
Hello JB7,
Thanks for your time, I got it done with help of selenium.
I am posting the code here so that it would be useful to others
Regards,
Ranjith
Code:
Public Sub ChromeLogin()
Dim MyHTML_Element As IHTMLElement
Dim Driver As New WebDriver
Driver.Start "chrome", "http://google.com/"
Driver.Open "https://incometaxindiaefiling.gov.in/e-Filing/UserLogin/LoginHome.html"
Driver.Type ("id=Login_userName"), ActiveCell.Value
Driver.Type ("id=Login_password"), ActiveCell.Offset(0, 1).Value
Driver.Type ("id=dateField"), ActiveCell.Offset(0, 7).Value
Driver.clickAndWait "css=input[type=""submit""]"
End Sub
 
Hi, Ranjith kumar!
Glad you solved it, yesterday I fell asleep. And thank you for sharing your solution with the community.
Regards!
 
Hi Ranjith,

I tried your code to work with chrome. but not sure why i'm getting pop-up as "Objet variable not set", also downloaded Selenium Webwrapper library and enabled reference.

getting error at line 3... please help.
Line: Public Sub ChromeLogin()
1 Dim MyHTML_Element As IHTMLElement
2 Dim Driver As New WebDriver
3 Driver.Start "chrome", "http://google.com/"

Actually i want to apply this code for another website. Please help.
 
Back
Top