+ Reply to Thread
Results 1 to 9 of 9

website login through vba

  1. #1
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    website login through vba

    Hi,

    Need some help with someoone with knowledge of website login via Excel. Below is the html code for section of the login page.

    HTML Code: 
    I used to be able to login to a similar website using:

    Please Login or Register  to view this content.
    where the username and pasword would go, but this is not working with this site even thought they use the same proxy system. I think it have to do with the design of the webpage here Form --> Table --> TBody --> TD --> Input instead of Form -->Input in the other website.

    Could someone show me what I am missing?

    abousetta
    Last edited by abousetta; 03-04-2012 at 03:31 PM.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  2. #2
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: website login through vba

    Hi Ab,

    When I 'view source' of the url contained within the HTML you offered, I get different name and password values to be queried. I'm thinking it might be as easy as changing the
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    and the
    Please Login or Register  to view this content.
    to
    Please Login or Register  to view this content.
    I was successful in passing a username, password, and clicking the submit button with the following. Hope this helps, -as-

    Please Login or Register  to view this content.
    Perhaps it was the Noid who should have avoided me...
    If you are satisfied with my solution click the small star icon on the left. Thanks
    1. Make a copy of your workbook and run the following code on your copy (just in case)
    2. With excel open, press ALT+F11 to open the Visual Basic Editor (VBE). From the "Insert" menu, select "Module".
    3. Paste the code from above into the empty white space. Close the VBE.
    4. From the developer tab, choose "Macros", select the Sub Name, and click "Run".

  3. #3
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: website login through vba

    Hi @AlvaroSiza,

    Thanks for taking the time to look into this for me. Unfortunately it didn't work as I do not login to the website directly but through a proxy server. That's where the code I posted came from. I have attached a workbook with your code and the correct URL for the proxy. It gives me an error (Object required) at this line:

    Please Login or Register  to view this content.
    Any thoughts?

    abousetta
    Attached Files Attached Files

  4. #4
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: website login through vba

    Ab,

    Took a little work, but I was successful with the following. Let me know how it goes on your end. <HTML Manipulation can be tricky>

    Please Login or Register  to view this content.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: website login through vba

    As far as I can see/check this will do the same trick:

    Please Login or Register  to view this content.
    Last edited by snb; 03-04-2012 at 04:14 PM.



  6. #6
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: website login through vba

    SNB,

    I tried your offering and it fails at the first instance of .getElementByID. I had tried this, along with every other 'simpler' way of going about the problem prior to the ultimate collection loop.

    Ab,

    As I just stated to SNB, I would have preferred to take a simpler route in solving this one, but in this instance, I was unable to be successful without the loop. I would not be qualified to point out the pluses/minuses associated with each method as a general best practice. As you rightfully assumed, this way 'just worked'.

  7. #7
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: website login through vba

    Hi snb,

    Unfortunately your solution doesn't work because the username and password are to enter a proxy not the actual website. I am trying to fill the objects on "http://proxycheck.lib.umanitoba.ca/libraries/online/proxy.php?http://gateway.ovid.com/autologin.html" but your code errors at these two line:

    Please Login or Register  to view this content.
    with an error that an object is required.

    abousetta

  8. #8
    Valued Forum Contributor AlvaroSiza's Avatar
    Join Date
    09-19-2007
    Location
    Staffordshire
    MS-Off Ver
    2007
    Posts
    591

    Re: website login through vba

    I suppose you could borrow the With End With construct from SNB for efficiency and simplification. It would look like this:
    Please Login or Register  to view this content.

  9. #9
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: website login through vba

    Thanks everyone. I did some playing around and made one observation. The webpage is using 4 forms. The last form is the one that contains the username and password input fields. Therefore I made a slight modification to the last code above to appear as follows:

    Please Login or Register  to view this content.
    That way it doesn't have to loop through all the different objects but limits them to the ones in the last form.

    Now having said that, I still can't use the simple syntax to get it to work

    Here are the objects by TagName("Input") located in Forms(3) but I still can't seem to make it work
    Please Login or Register  to view this content.
    Anyways, I just wanted to post this in case anyone is interested. For me, the Collection method works and that's the important thing.

    Thanks again evveryone.

    abousetta
    Last edited by abousetta; 03-04-2012 at 09:40 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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