+ Reply to Thread
Results 1 to 12 of 12

Is it possible for a macro to log into a website

  1. #1
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Is it possible for a macro to log into a website

    Is it possible to set up a macro which will prompt the user to key in the user name and password and then the macro should use this information to log into a website with the username and password.

    The web site link is https://cognizant.service-now.com/navpage.do

    Some Info: If I go to Excel Menu "Data" and then click on "From Web" and then login to the website after which I can import a table, after one time password entry i can use data refresh to continuously grab the information. But even if I login using IE, if the session is expired on the excel window where I can fetch the data, the excel explorer still asks me to key in the password

    Any help on this would be much appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Is it possible for a macro to log into a website

    Hi,

    Are you familiar with creating userforms? If so, this is how you can create a prompt for a username and password. If not, let me know and I'll dummy up an example for you to have a look at.

    As for the logging into a website with this information, I have absolutely no experience, but a quick Google search will definitely point you in the right direction (I found a heap of useful links but it wouldn't let me paste ALL of them here, so I didn't bother pasting any sorry)

    Hope this helps

  3. #3
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    Thanks ajryan88,

    I am not aware...i ll google n see if this helps me...thanks you :-)

  4. #4
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    I just had a look at it. Its too big. If you are anyone is an expert in this, please check if you can help me create one so that I can cross this last milestone

  5. #5
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Is it possible for a macro to log into a website

    OK no problems, I will create a userform for you in the morning as a I have turned my computer off for tonight and am reading this from my phone.

  6. #6
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    That would be Awesome...This has kept be sleepless for sometime...Thanks

  7. #7
    Valued Forum Contributor
    Join Date
    02-08-2012
    Location
    Newcastle, Australia
    MS-Off Ver
    Excel 2007 and Excel 2010
    Posts
    1,429

    Re: Is it possible for a macro to log into a website

    Hi,

    Here is a userform that asks you to enter your username and password, and then stores those values in a variable so that you may use them later for logging into your website.

    For logging into a website using VBA, try one of these links:
    1. http://nhsexcel.com/how-to-use-excel...-to-a-website/
    2. http://www.mrexcel.com/forum/excel-q...d-website.htmlHope this helps

  8. #8
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    lemme check...was away on vacation

  9. #9
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Is it possible for a macro to log into a website

    Whats the final result you want?
    The webpage open and logged in - or do you want to pull data from that page?
    Please click the * below if this helps

  10. #10
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    The webpage open and logged in.

    Here is some observations. Even if I am logged in to this site from internet explorer, unless I go to the browser that comes up after going to Data>From web and then log in to the site, till then the connection will not work. Once I login, I can fetch data from webpage till the session gets expired. Once expired , I would have to do the repeat this again

  11. #11
    Forum Expert JasperD's Avatar
    Join Date
    05-07-2013
    Location
    Netherlands
    MS-Off Ver
    Excel 2016
    Posts
    1,393

    Re: Is it possible for a macro to log into a website

    If you use "data -> from web" you will still want to get (part) of the webpage downloaded, right?
    Is this always the same data or do you really browse around there and pick the elements / tables as you go?
    The reason why I ask this is because in excel you can get data pretty from web in several different ways

    1) use "data -> from web", which opens the webpage in the excel browser and then you download (part) of it. The *only* advantage this has is that you can "cherry pick" the data you want every time; but the process is excruciatingly slow and you cannot store login / pass indeed

    2) use an internet explorer object - the webpage opens in internet explorer ; you CAN store the login/pass this way and get data based on elements as well, but you'll have to pre-set which elements you want. This is slightly quicker, since IE is usually slightly quicker than the Excel browser

    3) use an MSXML2.XMLHTTP object - with this method you don't open the webpage at all, but get the website response as a string in VBA and then parse / use that. This is the quickest and cleanest method and you CAN store username/pass with it. However, the response you get will still need to be parsed / sifted and you cannot get for example pictures this way, just plain old data.

    There are more different ways, but these are the ways I have some experience with - I tried them all (in that order) and nowadays stick to method 3.

    However, for me to give you _any_ real advice on how to go about this, it's important to know what you finally want to do with the website and excel in the end.

  12. #12
    Registered User
    Join Date
    08-17-2013
    Location
    bangalore, india
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Is it possible for a macro to log into a website

    Its always the same data.

    If i cant store the login data using 'data from web' option then i think i ll check how to do this using step 3

    What i do is i go to the site, there is a table report there which i can copy or download.

+ 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. Macro: Retrieve value from website
    By Tian1 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-15-2013, 02:47 PM
  2. Opening website, getting data, closing website
    By beta_leonis in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-27-2012, 03:50 AM
  3. Web query(macro) from website help
    By SimonLee in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-18-2011, 04:24 AM
  4. Macro to interface with a website
    By Horaldo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-16-2010, 11:31 PM
  5. I want few website name for macro
    By irsath in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-02-2006, 08:10 AM

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