+ Reply to Thread
Results 1 to 10 of 10

Creating a Login Button for a Website

  1. #1
    Registered User
    Join Date
    05-18-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    11

    Creating a Login Button for a Website

    Hi all,

    I am relatively new to VBA but I'm enjoying figuring out new things in it.

    Right now I am trying to create a button in Excel that will automatically go to my university's log-in page and fill in my credentials. I already got a button like this working for my Gmail account. However, for my university login it does not seem to work. I have the following lines of code:

    Sub UniversityLogin()
    Dim IE As Object
    Dim MyUsername As String, MyPassword As String


    MyUsername = "MyUsername"
    MyPassword = "MyPassword"

    Set IE = CreateObject("INTERNETEXPLORER.Application")

    IE.Navigate ("www.myeur.nl")
    IE.Visible = True

    Do While IE.Busy: DoEvents: Loop

    Application.Wait (Now + TimeValue("00:00:02"))


    IE.Document.all.Item("Erna_ID").Value = MyUsername
    IE.Document.all.Item("Password").Value = MyPassword
    IE.Document.all.Item("loginbutton").Click

    End Sub
    The whole first part (opening the website) works fine. The bottleneck right now are the last three lines. I used the same lines for my Gmail login button (though there instead of ''Erna_ID'' I used "email address"). Basically what I cannot get to work is the code to recognize the correct text boxes called ERNA ID for username and Password for Password. Is there anyone who has got any tips on solving this for both this specific website (www.myeur.nl) and for any website in general? I would really like to learn how to do this for other websites (e.g. Facebook or LinkedIn) too.
    Last edited by JesseV92; 06-19-2016 at 06:49 AM.

  2. #2
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating a Login Button for a Website

    It is difficult to get help with login request as we do not know your login details.
    I will give you some pointers.

    The name and ID of the first input box is IDToken1 and IDToken2 for second box.

    IE.Document.all.Item("IDToken1").Value = MyUsername
    IE.Document.all.Item("IDToken2").Value = MyPassword
    IE.Document.all.Item("loginbutton").Click
    I would use getelementByID method for boxes, but as I said, there is no way testing if these line work as I do not have password and username to test it.
    Last edited by AB33; 06-19-2016 at 07:34 AM.

  3. #3
    Registered User
    Join Date
    05-18-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    11

    Re: Creating a Login Button for a Website

    Hi AB33,

    Thank you for your reply.

    Maybe I should rephrase my question. The problem with my Macro right now is that it does not recognize/find the text box. So in other words: I am trying to figure out how the Macro can recognize the area where it needs to put in my details. On the website im currently trying to make this work for (www.myeur.nl) there are two places where text needs to put in. There is a text box behind Erna ID (where I want to enter my/any username) and a text box behind Password (where I want to enter my/any password). Would you know how to make this work? It does not have to actually login yet, right now I am first trying to get it to put in any text in those two boxes (the values for MyUsername and MyPassword in the code).

    P.S., when I inspect the element in Internet Explorer the text box is indeed called IDToken1. However, this does not make it work for me?
    Last edited by JesseV92; 06-19-2016 at 07:41 AM.

  4. #4
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating a Login Button for a Website

    Because you have IDs and Names.
    Try
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-18-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    11

    Re: Creating a Login Button for a Website

    Ah thanks a million, now I understand your point in your first comment. These lines indeed do work.

    Now just one last thing: what would the code for the login button be then? Because the element there is a Name right (called "Login")?

  6. #6
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating a Login Button for a Website

    Ah, you now caught me. I left that line on purpose as I could not find the click or summit button.
    If the button has an ID or name, it would have been
    IE.Document.getElementById("loginbutton").Click
    This line will not work and will give you an error, but try it.

    IE.Document.forms(0).submit

  7. #7
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating a Login Button for a Website

    May be try one too

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-18-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    11

    Re: Creating a Login Button for a Website

    Hmm no neither of those seem to be working. I really do appreciate the effort though!

  9. #9
    Forum Expert
    Join Date
    03-28-2012
    Location
    TBA
    MS-Off Ver
    Office 365
    Posts
    12,454

    Re: Creating a Login Button for a Website

    Last dice before some one can have a go.
    Please Login or Register  to view this content.
    Change the values in jaysixela and 12qwaszx it your own details

    It is the damn JavaScirpt. I have not idea how it works

  10. #10
    Registered User
    Join Date
    05-18-2016
    Location
    UK
    MS-Off Ver
    2013
    Posts
    11

    Re: Creating a Login Button for a Website

    Hmm no still no luck... The JavaScript is indeed the bottleneck here. Perhaps someone else has any thoughts on this?

    Anyway, thanks again for all your help so far!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. VBA to login to a website
    By chrishtina in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 03-05-2015, 05:55 PM
  2. Website login
    By stangz71 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 01-28-2015, 08:14 PM
  3. [SOLVED] VBA To login to a website
    By Sun13Banjo in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-06-2015, 10:46 AM
  4. [SOLVED] VBA to Login to website
    By IanHyman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2013, 03:27 PM
  5. Using vba to login into a website
    By Jack7774 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-08-2013, 11:35 AM
  6. website login through vba
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2012, 09:32 PM
  7. Website login help
    By davemaddocks in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-19-2011, 10:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1