+ Reply to Thread
Results 1 to 13 of 13

Logging in to website using VBA, input fields have no ID

  1. #1
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Logging in to website using VBA, input fields have no ID

    Hi everybody,
    First of all, I'm kind of a newbie at VBA. I'm trying to log in to a website with a username and password using VBA, but the only pieces of code I know either input information into the fields by using getElementsById and then adjusting the .Value of the input field, or they loop through elements via "getElementsByTagName", but then I'm not sure how to adjust the value and put a username or password in there.

    My code is below; you'll probably find the relics of many efforts including copy/paste, etc.

    (BTW in case there's any confusion as to why there's no explicit password strings within the code, it's for security reasons, I don't actually want to store the login info anywhere--what I'm aiming for eventually is where I can press a button, a window pops up asking for name and password, and then once I type that in and press enter, the VBA code will just do everything on the website. A little ambitious, especially for a newbie, I know. I'm confident I can get all the other little parts done, and I did get this code working on Gmail, but I'm having trouble with this site in particular. (Knowing me, it's probably something small that I'm missing))

    Please Login or Register  to view this content.

    This is the HTML form:


    HTML Code: 

    How 'bout it, guys? What am I doing wrong?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Logging in to website using VBA, input fields have no ID

    The user and password fields both have names, 'USER' and 'PASSWORD respectively.

    They are also contained within a form.

    So if you can get a reference for the form you should able to access those fields.

    Mind you, there was mention of a pop-up. Do you mean a pop-up from the web site/page or do you mean a small form created by you where the user will enter their credentials?
    If posting code please use code tags, see here.

  3. #3
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Logging in to website using VBA, input fields have no ID

    Try this:
    Please Login or Register  to view this content.
    and similarly for the password.
    Post responsibly. Search for excelforum.com

  4. #4
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Logging in to website using VBA, input fields have no ID

    Thanks for the speedy reply!
    I'm sure there is a way, I just am not familiar with the syntax. would it be something like Set HTMLDoc.Login.USER.Value = "Username"?

    As for the pop-up, it would be great to have one that I make within Excel. I've created a window that I can enter data in and all that, but I do not yet know how to have the code store the data that's entered, at least in a way that I can access elsewhere.

  5. #5
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Logging in to website using VBA, input fields have no ID

    Thanks so much for your fast reply, but nothing happens. The webpage pops up, and there aren't any errors, but neither is anything popping into the username field.

  6. #6
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Logging in to website using VBA, input fields have no ID

    To get the form.
    Please Login or Register  to view this content.
    Then you can try something like this.
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Logging in to website using VBA, input fields have no ID

    Nada, the forms still aren't getting filled.

    Here's the complete HTML for the site, (I've omitted a couple small details because it's a work site)
    I'm noticing some javascript stuff here now. Could that be the reason?



    HTML Code: 
    Last edited by esvenk; 10-09-2013 at 07:52 PM.

  8. #8
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Logging in to website using VBA, input fields have no ID

    What exactly did you try?

  9. #9
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Logging in to website using VBA, input fields have no ID

    I tried your guys' suggestions. I suppose searching for how to use VBA with javascript code would do the trick, as that seems to be what the site is using for its text fields.

    Please Login or Register  to view this content.

  10. #10
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Logging in to website using VBA, input fields have no ID

    You shouldn't need to bother about the JavaScript.

    Mind you the only script in what you posted is only for resetting setting focus and submitting the form, nothing to do with what's entered in the fields.

    Can you post the URL?

  11. #11
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Logging in to website using VBA, input fields have no ID

    This works for me with the HTML saved in a local file and with the real URL which you initially left in your code:
    Please Login or Register  to view this content.

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Logging in to website using VBA, input fields have no ID

    Here's my variation which works with the HTML saved locally.
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    09-16-2013
    Location
    San Francisco, California
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: Logging in to website using VBA, input fields have no ID

    You guys are awesome, I really appreciate the help.

    Nothing has worked, I keep getting an error on

    Please Login or Register  to view this content.

+ 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. Logging in to a website using Excel
    By FRIEL in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-10-2011, 11:08 AM
  2. Excel - Logging on to a website
    By jsomer2000 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-15-2011, 12:55 PM
  3. Logging in a website with Macros
    By pink in forum Excel General
    Replies: 2
    Last Post: 12-14-2008, 07:24 PM
  4. Logging a website information.
    By Nneuromancer in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-18-2006, 08:25 AM
  5. Logging into a website
    By Jackblack1 in forum Excel General
    Replies: 0
    Last Post: 05-31-2006, 12:27 PM

Tags for this Thread

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