Hello !!
I am trying to login to a webpage using VBA, I am successful till to the place where i have to type the username and password, however i am unable to type the same getting error message as "Run-time error '424': Object required"
(i.e.) After i login to the webpage, i have to click the an option "Merchant Login" and then i have to enter the Username and password to go to the desired page.
Also i am not sure whether this will help or not after the error message when i click "Debug" it shows me where the error is in the VBA and after that when i click "Continue(F5)" button the username and password gets populated.
Here is the code
Code
Sub Login()
Set IE = CreateObject("InternetExplorer.application")
IE.Visible = True
IE.navigate ("https://sample.net")
Do
If IE.readyState = 4 Then
IE.Visible = True
Exit Do
Else
DoEvents
End If
Loop
Set ElementCol = IE.document.getElementsByTagName("a")
For Each link In ElementCol
If link.innerHTML = "Merchant Login" Then
link.Click
End If
Next
Do
If IE.readyState = 4 Then
Exit Do
Else
DoEvents
End If
Loop
IE.document.getElementById("USER").Value = "testID"
IE.document.getElementById("password").Value = "testPW"
End Sub
Display More
Here is HTML Code
Here is the HTML Link For the "Merchant Login" link
HTML
<div class="button-container">
<div class="button-oblong button-blue">
<script>document.write('<A HREF="'+merchantLoginURL+'">Merchant Login</A>');</script>
<a href="https://sample.net/portal/portal/ClientPortalApp/index.jsp">Merchant Login</a>
<span></span>
</div>
<div class="clear-link"></div>
</div>
For the Username and password
HTML
<div class="content-login">
<label for="USER">User ID</label>
<input type="text" id="USER" class="input-default" size="31" name="USER" tabindex="1" value="">
<span class="forgot-link">
<script>document.write('<A HREF="' +forgotUserIDURL +'">Forgot User ID?</A>');</script>
<a href="https://sample.net//publicS/publicServ/ClientEnrollment/forgotuserid.jsp">Forgot User ID?</a>
</span>
</div>
<div class="content-login">
<label for="password">Password</label>
<input type="password" id="password" class="input-default" size="31" name="PASSWORD" tabindex="2" value="" autocomplete="OFF">
<span class="forgot-link">
<script>document.write('<A HREF="' +forgotPasswordURL +'">Forgot Password?</A>');</script>
<a href="https://sample.net//publicS/publicServ/ClientEnrollment/forgotuserid.jsp">Forgot Password?</a>
</span>
</div>
Display More