VBA log in failing with getElementsByClassName

Southerncentralrain

Board Regular
Joined
Jul 6, 2008
Messages
115
I am trying to login to a website using VBA but I can't get it to click the submit button even though I do the things that I have found recommended. Any help would be greatly appreciated.
Below is the HTML of the form:

HTML:
<div class="pdForm login">
  <div class="pdLoginBox">    <div class="pdLoginBoxInner">
    <div class="pdLoginFieldTitle">        <div>Email Address</div>        <div class="register"></div>    </div>    <input type="email" name="email" value="" class="pdInput text" id="pdLogin-email">
    <br>    <div class="pdLoginFieldTitle">        <div>Password</div>         <div class="forgot"><a href="http://myaccount.asdf.com/retrievePassword.php" *******="pdRetrievePasswordCopyEmail(this);"> Forgot your Password?</a></div>    </div>    <input type="password" name="password" value=""  class="pdInput text" id="pdLogin-password">
    <div class="pdLoginBtn">        <input type="image" src="http://myaccount.asdf.com/skins/standard_custom/butLogin.gif" border="0" vspace="4">    </div>        <div class="pdRegisterBtn">    </div>
    </div>  </div> </div>



Here is the VBA that I have tried and it fills in the name and password but will not submit even through it runs the code without error.

Code:
[COLOR=#222222][FONT=Verdana]Sub Login()[/FONT][/COLOR][/FONT][/COLOR]
    Set IE = CreateObject("InternetExplorer.Application")


    my_url = "http://myaccount.asdf.com/login.php"


    With IE
        .Visible = True
        .Navigate my_url
        .Top = 50
        .Left = 530
        .Height = 1200
        .Width = 1200


        Do Until Not IE.Busy And IE.READYSTATE = 4
            DoEvents
        Loop


    End With


    ' Input the userid and password
    IE.Document.GetElementById("pdLogin-email").Value = "asdf@asdf.com"
    IE.Document.GetElementById("pdLogin-password").Value = "xxxxxx"


    Set ElementCol = IE.Document.getElementsByClassName("pdLoginBtn")


    For Each btnInput In ElementCol
        btnInput.Click
    Next btnInput


[COLOR=#242729][FONT=Arial][COLOR=#222222][FONT=Verdana]End Sub[/FONT][/COLOR][/FONT][/COLOR]


Any ideas? Thanks in advance for your time.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Have you tried submitting the form?
Code:
IE.document.forms(0).submit
 
Upvote 0

Forum statistics

Threads
1,223,728
Messages
6,174,150
Members
452,548
Latest member
Enice Anaelle

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