+ Reply to Thread
Results 1 to 9 of 9

VBA To login to a website

  1. #1
    Registered User
    Join Date
    06-08-2012
    Location
    Liverpool
    MS-Off Ver
    Office 365
    Posts
    84

    VBA To login to a website

    Hi.

    I am trying to set up a macro to login to a travel booking website that I use constantly at work. I have most of the code worked out, with the exception of being able to submit the form. Can anyone help with the final step?

    My code is;

    Please Login or Register  to view this content.
    Thanks in advance

    Banjo

  2. #2
    Registered User
    Join Date
    09-01-2011
    Location
    georgia
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: VBA To login to a website

    The link below seems to have had the same issue as you. Their solution appears to be to use the below line of code. (Not mine so I'm not sure if it will work)
    http://www.mrexcel.com/forum/excel-q...button-ie.html
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    11-12-2014
    Location
    New York
    MS-Off Ver
    2010
    Posts
    28

    Re: VBA To login to a website

    Have you considered using selenium-vba? It seems like you can record your actions with a Firefox plug-in and translate those actions into VBA code.

    https://code.google.com/p/selenium-vba/

  4. #4
    Registered User
    Join Date
    06-08-2012
    Location
    Liverpool
    MS-Off Ver
    Office 365
    Posts
    84

    Re: VBA To login to a website

    Thanks Persecuted. No joy I'm afraid.

    ExcelClout, I use this at work and can't install Firefox of plugins.

    Sun

  5. #5
    Registered User
    Join Date
    09-01-2011
    Location
    georgia
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: VBA To login to a website

    Well this sounds like it will be dependent on the website itself. If you're able to provide the address for the login page then I can take a closer look tonight. Feel free to PM it if necessary.

    Edit:
    I happened upon some code for VBA that may work for you. I tried to tailor it to your solution so see if this will work in place of your code block. To find the name, id, etc. of the text box or button you can use the developer tools of Internet Explorer. Activate it with F12, then press Ctrl+b to enable the Selection tool. When you click on your text box or button the window will highlight the line of code pertaining to that particular control. I have a similar C# script that I use but I borrowed this code rather than translate my own to VBA to avoid some headache.

    The IE window won't show until after you're logged in. Change the first IE.Visible to True to see it's progress while running.

    Please Login or Register  to view this content.
    Last edited by persecuted; 01-05-2015 at 03:40 PM. Reason: added some code.

  6. #6
    Registered User
    Join Date
    06-08-2012
    Location
    Liverpool
    MS-Off Ver
    Office 365
    Posts
    84

    Re: VBA To login to a website

    Thanks again Persecuted.

    The code above stopped at the line objElement.Click and didn't anter my user name or password.

    THe site I want to login to is https://businesstraveldirect.evolvi.co.uk/Default.aspx

  7. #7
    Registered User
    Join Date
    09-01-2011
    Location
    georgia
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: VBA To login to a website

    This appears to do the trick. You'll obviously have to replace your login name and password where it says "YourUsernameHere" and "YourPasswordHere" to log in.

    Please Login or Register  to view this content.
    If this works for you, please mark the thread as solved

  8. #8
    Registered User
    Join Date
    06-08-2012
    Location
    Liverpool
    MS-Off Ver
    Office 365
    Posts
    84

    Re: VBA To login to a website

    Persecuted, that is brilliant! The code works perfectlly - now to work through it so I can replicate this for other sites.

    Many thanks for all you help.

    Sun

  9. #9
    Registered User
    Join Date
    09-01-2011
    Location
    georgia
    MS-Off Ver
    Excel 2010
    Posts
    47

    Re: VBA To login to a website

    Happy to help. To find the different IDs for the text boxes and buttons, you can use the Developer Tools in Internet Explorer to locate the line of HTML with that information. That's where I got the "ctl00_MasterContent_LogonWebPart_Email" and other similar IDs.

    Best of luck!

+ 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. Login into website
    By jharaldson in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-10-2013, 10:55 AM
  2. [SOLVED] VBA to Login to website
    By IanHyman in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 05-28-2013, 03:27 PM
  3. 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
  4. website login through vba
    By abousetta in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-04-2012, 09:32 PM
  5. 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