locked
Using VBA To Automate IE and input user name, password, and hit submit RRS feed

  • Question

  • *************************************************************************

    how to give username and pasword through vba and hit abutton in web page..

    pls give me solution 

    ********************************************************************

    I'm trying to use <acronym style="border-width:0px 0px 1px;border-bottom-style:dotted;border-bottom-color:#000000;cursor:help;" title="visual basic for applications">VBA</acronym> to go to a website that requires a User Name, Password, and a Submit Button.

    So far I can get everything to work besides the Submit part. The code runs without errors, but doesn't actually "hit" the submit button on the webpage. 

    For posting, I removed my actual user name and password and and used the generic "User Name" and "Password" highlighted in blue. 

    I highlighted another section in green that I took from a previous post hoping it would solve my problem. The link is: Automating with Internet Explorer


    Here is the code I am using:

    Sub GoToWebSiteAndPlayAroundNew()

    Dim appIE As Object ' InternetExplorer.Application
    Dim URL As String



    Set appIE = CreateObject("InternetExplorer.Application")
    URL = "https://efolio.morgankeegan.com/escripts/defaultLogon.asp?errCode=2"


    With appIE
    .navigate URL
    .Visible = True

    Do While .busy: DoEvents: Loop
    Do While .ReadyState <> 4: DoEvents: Loop


    .document.getelementbyid("fUserName").Value = "UserName"
    .document.getelementbyid("fPassword").Value = "Password"


    End With


    On Error Resume Next
    x = 0
    For Each mitem In IE.document.all
    mitem.Value = "x"
    x = x + 1
    Next


    x = 0
    For Each mitem In IE.document.all
    If x = "Submit" Then
    mitem.Click
    Exit For
    End If

    Next


    End Sub

    Friday, September 25, 2015 3:56 AM

All replies

  • Hi rammi,

    This forum is for developers discussing developing issues about Office add-ins. Since the issue is more relative to VBA, I would like to move it to VBA forum.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us.

    Thanks for your understanding.

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Monday, September 28, 2015 2:55 AM
  • Please see the example here.

    http://vbadud.blogspot.com/2009/08/how-to-login-to-website-using-vba.html

    That should do what you want.


    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    Saturday, October 10, 2015 1:27 PM