How to Login into Website Automatically Using VBA

Share
Embed
  • Published on Jul 3, 2013
  • Alex wants to automate the process of logging into a website automatically using Excel VBA. He has the username and password for the website.
    Our video demonstrates how you can login automatically into a website like Gmail using Excel VBA:
    1. Go to the Gmail website
    2. View its source code to find out the labels used for the username and password
    3. Start the Visual Basic Editor in MS Excel
    4. Activate the following two items by clicking on Tools and then 'References...':
    •Microsoft Internet Controls
    •Microsoft HTML Object Liabrary
    5. Next define two public variables
    6. Now start writing the macro
    7. Using a looping process access the username and password text-boxes automatically for entry of the relevant data
    8. Then identify the 'submit' button, click on it and exit the for loop
    9. To avoid error messages popping up write a few lines of code to ignore the errors
    You'll notice that the VBA code works well.
    You can access the VBA code here:
    www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/
    For more knowledge read the book Excel 2016 Power Programming with VBA: amzn.to/2kDP35V
    If you are from India you can get this book here: amzn.to/2jzJGqU

Comments • 214

  • Knowledgie Mangezi
    Knowledgie Mangezi Month ago

    this will just make my app number1 thank you sir
    but however my case is not logging into email its another website

  • parveen rohilla
    parveen rohilla Month ago

    Hello sir
    If we have sha256 encription on client side in password. Then what to do??
    TIA

  • Kingsley Simon
    Kingsley Simon Month ago +1

    thank you sir...twas a grate tutorial for me..

  • Sysana Tek
    Sysana Tek Month ago

    Sir,
    I want to collect data from a password protected site to excel. Can you help me sir?

  • Brilliant Techno Tech

    Muje FNO Stock ke option chain ka data automatically excel me pull karna hai vba ke dwara bata do

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Month ago

      This link will help:
      www.exceltrainingvideos.com/get-external-data-from-the-web-into-excel-in-hindi/
      Or search www.exceltrainingvideos.com

  • Ted Bobit
    Ted Bobit 2 months ago +1

    Thanks very much bro ! !!!!!!!!!

  • Zack Ul-Haq
    Zack Ul-Haq 3 months ago

    Hi dinesh hope you are well.
    I work for insurance and we use about 10 different websites.
    My issue is that because of data protection we have to reset passwords on a monthly basis.
    Is there a way for the code to obtain user name and password from the excel spreadsheet instead of predefining?
    Also can the code then be saved as a hyperlink so I can access relevant portals as and when required?
    Many thanks in advance for your response

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 months ago

      These links will guide:
      www.exceltrainingvideos.com/compare-userform-data-with-worksheet-data/
      www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/
      Or search www.exceltrainingvideos.com

  • Khushi Gaur
    Khushi Gaur 3 months ago

    Thanks for the reference video, kindly suggest as how to capture error if it shows email address is not valid
    ..and store in excel as "error"... Next to email address

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 months ago

      This link will guide: www.exceltrainingvideos.com/how-to-capture-user-input-via-input-box-and-validate-the-data-input-using-excel-vba/

    • Khushi Gaur
      Khushi Gaur 3 months ago

      Thanks but am not a programmer but will try to find more

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 months ago

      Use an IF condition.

  • Roger St-Onge
    Roger St-Onge 3 months ago

    The link to the code is no longer active

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 months ago

      Here's the new link: www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/

  • Khushi Gaur
    Khushi Gaur 3 months ago

    Great video, but in my case a new web page loads when click on submit, and here im not able to select the active web page element ID to fill the data from excel sheet, kindly suggest.

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 months ago

      This link could be useful: www.exceltrainingvideos.com/tag/extract-data-from-web-pages-using-data-miner-chrome-extension/
      Or search www.exceltrainingvideos.com

  • Nikhil Nikki
    Nikhil Nikki 4 months ago

    It is ok for gmail..but What if there was captcha enter sites?

  • J M TIWARI
    J M TIWARI 5 months ago

    Yes. Really useful. However, in case of captcha to be entered, how to go to the box where captcha is to be entered ?

  • CyberNaut WA
    CyberNaut WA 5 months ago +1

    For a change someone gives a tutorial with the "CODE" :) :) Hopefully you will inspire others to follow same rather making it a complicated mystery :(

  • Fernando Moreira
    Fernando Moreira 6 months ago +1

    This was very useful, thank you!

  • Gary'Lee Humphreys
    Gary'Lee Humphreys 6 months ago

    THANK YOU, STILL WORKS! (for me anyways)

  • pancux670
    pancux670 7 months ago

    Nice explanation Sir.
    Can we also login websites asking for captcha through this type of excel macro?

  • Ravi Purohit
    Ravi Purohit 8 months ago +1

    sir i want to log in to gst portel, can you please help me out

  • Tanveer Khan
    Tanveer Khan 9 months ago

    HTMLDoc.all----------------Property not found

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  9 months ago

      Activate the following two items by clicking on Tools and then 'References...':
      •Microsoft Internet Controls
      •Microsoft HTML Object Library

  • Gugudu Kullaiswamy
    Gugudu Kullaiswamy 10 months ago

    Sir, I want to download the files automatically from website.. That to in that website one download button is there in that it want to select "download as CSV" option.. Then the file will download.. So is there any script for this..

  • fenny snow
    fenny snow 10 months ago

    Hii

  • Official Training

    This not working in present gmail login, only opening gmail login stopped

  • Milind Bidve
    Milind Bidve Year ago

    I need to login to one website with user name and password., click on login button. Then click on Run, allow button. then click on Diagnostic button. How to automate this next 3 clicks? can you please give complete code including this additional click. It is really urgent, kind request.

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Login help: www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/ You need to study the HTML code of the website.
      For the next 3 clicks: www.exceltrainingvideos.com/how-to-follow-multiple-hyperlinks-and-extract-webpage-data/
      Again you'll need to study the website HTML code carefully.

  • Martin Rajith
    Martin Rajith Year ago

    Hi sir,
    It is possible to convert pdf to excel through vba . If possible can you send me the vba code

  • Santhosh Sivan
    Santhosh Sivan Year ago

    Thank you for your session ... It really helps. Could you please tell me how to perform the same with Google Chrome

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Check out this link: www.exceltrainingvideos.com/send-email-using-gmail-with-excel-vba/
      Please note that websites keep on changing their code. You'll have to take appropriate action.

  • Sangram Ghatge
    Sangram Ghatge Year ago

    I have HTML and need to update URLs without editing the HTML is there any possible way to do so, please advice.

    • Sangram Ghatge
      Sangram Ghatge Year ago

      yes, i'm aware about that. But i have 700 email templates and list of URLs in excel. The manual work is too much of pain. So i was looking for automated way to do so? Any help ?

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Use Find and Replace.

  • MARI SELVI M
    MARI SELVI M Year ago

    Sir, This is very useful.But I want to know how to login to Etoken automatically using Excel VBA.Can you please help me, sir.

  • Shehnaz Banu
    Shehnaz Banu Year ago

    Hi sir need help regarding vba code to login into a site and make changes in that site and then i need to sav it... Pls help me

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      If you have the login credentials you should be able to perform the required tasks. . This link will guide: www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/

  • Hoorn Zwaag Zonnepanelenwestfriesland

    Hi Thank you very much for you tutoriol

  • superoriginalname

    Hi Dr. Takyar, could you please do an update for the new Gmail interface. One of the issues with this version is that Gmail now has a new button to click between username and password. It's quite difficult to get VBA to click the "Next" button, I've been stuck at this stage for quite some time, could you please let us know how to do this?

  • Endre111
    Endre111 Year ago

    What can I do if there is no label for the password and login in the source code of the website I would like to log on?

  • Essam Adel
    Essam Adel Year ago

    If website when right click can't see view source what can i do ?

  • Amit Singh
    Amit Singh Year ago

    Hi sir,
    While using your code, I am getting a Compile error: User-defined type not defined. Please help me .

  • Parvathi Vaindam
    Parvathi Vaindam Year ago

    I got a error in line 1 "Dim HTMLDoc As HTMLDocument" as User-defined type not defined

    • César Rodriguez
      César Rodriguez Year ago

      You probably didn't activate "Microsoft Internet Controls" or "Microsoft HTML Object Library" in Tools -> References.

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Please read the description accompanying this video.

  • undecided
    undecided Year ago

    Hello Dinesh, I would really appreciate if you can answer my question. How can I transfer your script from Excel VBA to a VBScript Script File (.vbs) and make it functional? Thank you!

  • Satish kumar Pandey

    Hello sir please help me..
    I want to use source url as a url for fatch data using vba macro how is possible please help me
    Thanks

  • Punna Rajeev
    Punna Rajeev Year ago

    compiler Error:
    User-defined type not definded

  • mithun nair
    mithun nair Year ago

    Hello sir,
    Thanks for this video which really help me to understand new thing and able to build similar vba. But when i try to run the same code with one of my project based web application which work on a secured intranet environment... I am getting back to back error after below line
    MyBrowser.Visible = True
    (i understand this when i run this code in debug mode, after removing the err_clear tag) the error i am getting is "AUTOMATION ERROR THE OBJECT INVOKED HAD DISCONNECTED FROM ITS CLIENTS" is there any solution for this kind of issue?

    • mithun nair
      mithun nair Year ago

      If fact i find a solution if u set Mybrowser = New InternetExplorerMedium this issue will be fixed.... Thanks

  • Melvin Bellamy
    Melvin Bellamy Year ago +1

    Thank you so much for your informative videos. Your explanations are clear and the topics are useful. Moments after inputting the code and customizing it for my needs, it was functioning perfectly.

  • 1234 1234
    1234 1234 Year ago

    Hi Sir, I have tried this but not succeed could youplease help me with auto login in SSMMS site,
    Thanks in advance

  • Swapnil Wankhede
    Swapnil Wankhede Year ago

    Thanks a lot. Very good video.
    Could you please help me on this line “If MyHTML_Element.Type = "submit" Then”?
    When should we use submit? I tried to login on different URL, I could able to inert username and password but it got failed when tried to login, so I took help from one of my friend he is SharePoint developer.
    To click on Login button I used “HTMLDoc.all.loginButton.Click”
    How to identify the code for clicking on the button from HTML script?
    Thanks in Advance

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      www.exceltrainingvideos.com/how-to-login-automatically-into-website-using-excel-vba/

  • Zoom In
    Zoom In Year ago

    I need code the same way but for a program

  • sanjay singh
    sanjay singh Year ago

    thanks à lot sir ,
    I request to solve my problem
    I am a trader and I want to create a button in excel which can login to my Zerodha account and also place order according to cell live value of script and execute it

  • Sonika Vasanth
    Sonika Vasanth Year ago

    Hello Dinesh Sir,
    Im following your tutorials and understood lot of things for a beginner like me. My Job is automating the process to generate reports to excel. I understand HTML Code but I dont have enough knowledge about microsoft access - experience . Do you recommend any books to start learning which which help me to understand or any courses to choose from. Any help is highly appreciated thanks.

  • Devender G
    Devender G Year ago

    HI sir, I am very much thank full for such video. Thru you i came to know how to write VBA code in Excel. Can I get any solution to fill autofill CAPTCHA or pull down the captcha without typing.

  • Avinash Mishr
    Avinash Mishr Year ago

    How can I login Window application and pull data daily basis using VBA. Please guide us.

  • Parvinder Singh
    Parvinder Singh Year ago

    Hello Sir,
    How do I clear the existing data present under Email address box and enter new data .
    For example, I'm working on Automating and raising a Ticket and I've saved a Quick link for that. The quicklink for that ticketing website isn't being saved unless I enter some text in it. So, I wrote "test" under description section of the Ticket.
    I'm trying to pull the data from Excel Cells, and pasting it under description. But the text isnt being pasted under description section and it says test even after macro is run successfully.
    I've inspected the element and I'm looking at correct section.

  • Logan Thouvenell
    Logan Thouvenell Year ago

    This is a great video and so easy to understand. The issue I have with trying to open a Web page is it says something about cookies which would be because the site is already saved to auto login when I go since I'm using a domain login all passwords for my sites that I need are stored so I don't have to enter them but if I program the macro to go to the site it gives an error about cookies

  • Luiz Bocchese
    Luiz Bocchese Year ago

    HELLO!!!
    Man! You save my life!!!
    Thank you for this simple but powerful tip!!!

  • Essam Adel
    Essam Adel Year ago

    when start mecro "Dim MyHTML_Element As IHTMLElement" and " New InternetExplorer"
    not working why?

  • rajender rajender

    sir im nt getting that code

  • rajender rajender

    hello sir ,
    where can we download excel vba??

  • Venkat Reddy
    Venkat Reddy Year ago

    hi... I tired your code... while running it up.. it takes up login I'd and password.. tats it.. not loggin.. help me out

    • Venkat Reddy
      Venkat Reddy Year ago

      Dinesh Kumar Takyar do this code work in excel 2010.. becoze .click function is not responding I think so

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Check out this link carefully: www.familycomputerclub.com/how-to-login-automatically-into-website-using-excel-vba.html

  • karthik veeram
    karthik veeram Year ago

    How to update website field using VBA

  • Venkat Reddy
    Venkat Reddy Year ago

    while I execute the same code.. I get next without for error.. how to clear this

  • Chandana Don
    Chandana Don Year ago

    Dear Sir Kumar,
    Where do we save this VBA file in the computer please so that I want to log in for about 20 websites automatically and keep me logged in for x amount of hours.
    I appreciate your time and free lectures.
    Thank you
    Chan

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Watch this video carefully at 00:37 minutes: www.exceltrainingvideos.com/ms-excel-essentials/microsoft-office-button/
      Save your file as a 'macro enabled workbook' in a folder of your choice.

  • CHANDAKA ASHOK
    CHANDAKA ASHOK Year ago +3

    hello dinesh sir,
    I want help from you sir, please make a video for data entry from excel to internet explorer, to enter a lot of data in loop proceses. and also please help me to go through hyper links in ie and click one particular hyper link through vba.
    actually im working in a company, we are having a tool to update a date from excel. actually I got this idea to update the data through vba automation. sir, if you can help me it very usefull to our team.I have learnt so many things from you exceltrainingvideos.
    thank you sir.
    awaiting for your reply.
    regards,Ashok chandaka.

  • Vivek Kashyap
    Vivek Kashyap Year ago

    I have a situation, I am working on a data entry automation in a website.. it works fine till I login and go to a required link.. here I click on an icon and another small window opens (not another instance of IE or tab, just within) where I have to fill some information and click submit.. I am not being able to control this small window.. it says object not found, please help

    • Vivek Kashyap
      Vivek Kashyap Year ago

      Dinesh Kumar Takyar I actually haven't read the HTML code fully.. I just refer to get ids and names for the vba codes

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Did you study the HTML code carefully?

  • hemanthmaharana
    hemanthmaharana Year ago

    Hello,
    The code is very good thanks for your amazing video
    I have one query about is it possible we can Automate any website ? like an example placing online Amazon order using VBA macro if yes could you provide any materiel how to do.

  • kdvirtualimage
    kdvirtualimage Year ago

    Hello, it is a very nice VBA , but can you make it to login into Gmail 2017 because it doesn't work any more.mvgKurt

  • Fahim zaidi
    Fahim zaidi Year ago

    what if we try with website not email

  • Jenessa Johnson
    Jenessa Johnson Year ago

    How do I scrape the data from a website that requires log in first? Followed your other video but when I put in the website url and press go, nothing happens.

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      Search my channel or website exceltrainingvideos.com

    • Jenessa Johnson
      Jenessa Johnson Year ago

      I saw how to create the code to log in automatically but how do I combine that with scraping?

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  Year ago

      This link will help: www.exceltrainingvideos.com/3-excel-vba-training-questions-on-youtube/
      Or search www.exceltrainingvideos.com

  • arthi ravi
    arthi ravi 2 years ago

    Hello,
    I try to pass some value is webpage but some value is not mandatory
    if i dont put any value in excel it is taking some buffer value as "UNDEFINED "
    Please help me on this
    Thanks,
    Arthi

  • Alyssa Lamport
    Alyssa Lamport 2 years ago

    My source code uses names with spaces, and the code won't with the source code names that have spaces. How do I get around this?

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago

      We can't use a space, period (.), exclamation mark (!), or the characters @, &, $, # in the name.

    • Alyssa Lamport
      Alyssa Lamport 2 years ago

      The code otherwise works for items that have one word source code names.

  • Amit Bodhwani
    Amit Bodhwani 2 years ago

    Hi Sir,
    I have a button called UpLoad on my webpage which ask to upload the .csv file.
    I am able to click that button using VBA code and after clicking that button on webpage a popup appears similar to open dialog box which ask to upload a file for example say "Star.csv" but i want to insert the file name called "Star.csv" which is stored in my local directory automatically using VBA without user interaction.
    Any help will be appreciated .
    Thanks!

  • Amit Bodhwani
    Amit Bodhwani 2 years ago

    Hi Sir,
    Thank you for your quick reply it solved my issue now i am able to click it also i need one more help is there any way to upload excel file from our local disk to webpage i am able to do it using Java-Selenium but i am not sure how to do it using VBA.
    Thanks

  • Amit Bodhwani
    Amit Bodhwani 2 years ago

    Hi Sir,
    There is a text box on my webpage which on clicking will pop up a calendar the properties of that text box is

    I tried clicking that button using IE.document.getelementbyid("datepicker") and IE.document.getelementsbyclassname("hasDatepicker") and also IE.document.getelementsbyname("date") but i failed everytime and i am not able to click text box because of which the calendar on my webpage is not appearing.
    I tried using Selenium Java code and it is working fine with it but i want to code with VBA scripting.
    Please help me with this issue as while running i am not getting any errors also.
    Thank You

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago

      Try this code:set input_elements=IE.Document.getElementsByTagName ("input")
      For each input_element in input_elements
      If input_element.getAttribute("name")= "date" then
      input_element.Click
      Exit For
      End if
      Next input_element

  • Rishikesh
    Rishikesh 2 years ago

    do we need to enable any libraries to run this code ??

  • 123789s1
    123789s1 2 years ago

    GMail already keeping your credentials/password - no need for any macro. Show example where this other dialog box pops up, one, that does not allow for credentials to be kept.

  • uday Mudumba
    uday Mudumba 2 years ago

    Here is my source code for log on button:
    Log on

    I am not able to click on this button. Can you help me here? Thanks.
    Uday

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago

      This link will help: www.exceltrainingvideos.com/scraping-web-page-data-automatically-with-excel-vba/
      Or do a search at www.exceltrainingvideos.com

  • Ranjana Verma
    Ranjana Verma 2 years ago

    Hi Sir Thanks for creating such a useful micros to make things easier. i am trying to do automate but unfortunately it's not working properly so I need your help to resolve issue. it's working perfectly but till the ID password after that it's not auto login I need to click manually and am also not able to find source codes label for ID & Password. if you need portal name I can give you that as well. Please help me I really appreciate your help.Thanks

  • Joby John
    Joby John 2 years ago

    how to create an automated script that would auto login to a particular application with a specific user name and password? Can you help me to create those?

  • CeeDubYuh
    CeeDubYuh 2 years ago

    That was freaking awesome!

  • yOmAN123
    yOmAN123 2 years ago

    Great. But, these days URLs work better with higher browsers like Chrome/Firefox. It will be awesome if you can link it to VBA similarly for automatic login.

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago

      This link might help: www.exceltrainingvideos.com/send-email-using-gmail-with-excel-vba/
      Or do a search at: www.exceltrainingvideos.com

  • Varshan M
    Varshan M 2 years ago

    Hi Thank you for the valuable video. Can you please explain how to do this same activity in google chrome or firefox?

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago

      This link might help: www.exceltrainingvideos.com/3-excel-vba-training-questions-on-youtube/
      Or do a search here: www.exceltrainingvideos.com

  • Mahmoud Hammash
    Mahmoud Hammash 2 years ago

    Can you please help me how to write aVBA code for any eccomercial website to import specific data like order ID and tracking No. and more criteria from my account, and could I make some data updated automatically depending on its status on the website? i mean like if the status online is shipped and then get delivered so it is updated automatically on exel sheet
    would highly appreciate your reply & thanks in advance

    • Mahmoud Hammash
      Mahmoud Hammash 2 years ago

      appreciate your reply :) .. as I'm beginner, I just was wondering if it's possible or just need a specialized and professional guy who can develope .. so if it's possible with some effort and a little reading, so I can go ahead, but if it's complicted I'll just put it off for next time..
      Thanks again & Regards

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  2 years ago +1

      Do a search at www.exceltrainingvideos.com

  • Ravi Raval
    Ravi Raval 2 years ago

    Hi Dinesh Kumar Takyar,
    i watched your video and found very useful. But in some site there might be blocked submit button, i am putting the html code here , can u please give me vba code to enable the submit button and login to web page easily.




    Log In

    Thanks in Advanced
    Thanks,
    Ravi

  • Ruben Rosado
    Ruben Rosado 2 years ago

    The code was exactly what I needed. Thank you so much!!!

  • venu gp
    venu gp 2 years ago

    Please explain how to fetch the data(gmail id and password) directly from excel only

  • Ashmid Ahmed
    Ashmid Ahmed 2 years ago

    Hi i would like to know how to use vba macro to input text and click OK in a input box in excel which will be used to unprotect all worksheets in the workbook. The current sendkeys codes are not inputting the password into the input box

  • SANJAY AGRAWAL
    SANJAY AGRAWAL 3 years ago

    using vba code given by you, unable to loging gmail. it just open the loging screen.
    sanjay agrawal
    9893284675

  • mahesh sharma
    mahesh sharma 3 years ago

    Password is not entering while running this code
    need to fix it

  • pubg rocz kamesh
    pubg rocz kamesh 3 years ago

    HI,
    can anyone provide me the video clip for how to login the chrome using Macro in existing Tab and also please show me how to paste the bulk data from excel to n text boxes....

  • Mano Ranjan
    Mano Ranjan 3 years ago

    Hi Sir,
    If the User Name and the pass word field is popup, inside the field the user name and password item is engraved. How can I modify this code.
    Please provide reply.
    Thanks in Advance,
    Mano.

  • Anita Mallya
    Anita Mallya 3 years ago

    Dinesh, Thank u for all your efforts. I want to give feedback to you and that is nowadays Gmail is not allowing such sign in as it detects automatic (programmatically) attempts to login. Just now I tried this code and it just locked my account and told me to go thru Recovery Process to Log in my Account. So somehow they know that someone is trying to log into Gmail programmatically.
    Now my question to you. How to solve my problem given below. If you know how to do it kindly do tell me (or all your viewers) in this forum. I wrote this following code because I wanted to download NSE's Data.CSV file from their site. In the web page there is fromDate and toDate (Item IDs) and Get Data button (Item Id: "get"). I could successully run the following code and the site showed me an HTML Table and a link "Download file in csv format". But, I don't know what to do to click that link ("Download file in csv format" programmatically as there is no Item ID that can be found even if I tried to see the Source code of that page. So how to accomplish that? That is, programmatically clicking the "Download file in csv format" link that is presented to us below the HTML Table that we get after programmatically clicking on "Get Data" button.
    Here's the code:
    oBrowser=CREATEOBJECT("Internetexplorer.application")
    tcURL="www.nseindia.com/products/content/equities/indices/historical_index_data.htm"
    oBrowser.navigate(tcURL)
    DO WHILE NOT oBrowser.ReadyState=4
    endd
    oBrowser.Visible=.t.
    oBrowser.Document.GetElementbyID("fromDate").value="01-02-2016"
    oBrowser.Document.GetElementbyID("toDate").value="31-03-2016"
    oBrowser.Document.All("get").Click(0)

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 years ago

      +Anita Mallya I've also indicated this login problem at 3.44 min onwards in the video and therefore done a 'error' handling. This link might help to download the csv file: www.exceltrainingvideos.com/tag/how-to-follow-link-on-web-page-automatically-with-vba/

  • gordoha
    gordoha 3 years ago

    FYI, the entire first minute of your video was a total waste of time.

  • EL34XYZ
    EL34XYZ 3 years ago

    Hi Dinesh. Thank you for your great tutorial. The web page I am trying to log into has this for the email login.
    Email Address (required)
    Every time I try and change your code to "login-email", it changes automatically to this.
    HTMLDoc.all.login -Email.Value =
    Notice the space after the word login and a capital E on the word email
    How come I cannot change the code to "login-email"
    Thanks for your help

  • Matthew Mglej
    Matthew Mglej 3 years ago

    Holy Smokes Din Your amazing I learned so much. I tried with google and they changed a few things. First you have to click login now, to fix that I just Used the Web address for the Login page. Next it only asks for your Email first then once you enter it, then it asks for your password. I just simply copied your loop twice and made the first loop for email then second loop for Password.

    • Maheswaran K
      Maheswaran K 3 years ago

      +Matthew Mglej Thank you. It is working when I break the lines and run the code. If I directly click the run button it is throwing a Run time error: 438 in the below line.
      HTMLDoc.all.passwd.Value = "PASSWORD HERE" 'Enter your password here

    • Matthew Mglej
      Matthew Mglej 3 years ago

      +Maheswaran K

      Dim HTMLDoc As HTMLDocument
      Dim MyBrowser As InternetExplorer
      Sub MyGmail()
      Dim MyHTML_Element As IHTMLElement
      Dim MyURL As String
      On Error GoTo Err_Clear
      MyURL = "accounts.google.com/ServiceLogin?service=mail&continue=mail.google.com/mail/#identifier"
      Set MyBrowser = New InternetExplorer
      MyBrowser.Silent = True
      MyBrowser.navigate MyURL
      MyBrowser.Visible = True
      Do
      Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
      Set HTMLDoc = MyBrowser.document
      HTMLDoc.all.Email.Value = "EMAIL HERE" 'Enter your email id here
      For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
      If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
      Next
      Do
      Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
      Set HTMLDoc = MyBrowser.document
      HTMLDoc.all.passwd.Value = "PASSWORD HERE" 'Enter your password here
      For Each MyHTML_Element In HTMLDoc.getElementsByTagName("input")
      If MyHTML_Element.Type = "submit" Then MyHTML_Element.Click: Exit For
      Next
      Err_Clear:
      If Err 0 Then
      Err.Clear
      Resume Next
      End If
      End Sub

    • Maheswaran K
      Maheswaran K 3 years ago +1

      +Matthew Mglej can you please share me that updated code. Thank you

  • Maheswaran K
    Maheswaran K 3 years ago

    Hi Dinesh,
    Can you please help me with the new gmail website.
    I am getting "object variable or with block variable not set" error after the email ID got entered. Thank you.

    • Maheswaran K
      Maheswaran K 3 years ago

      +Anita Mallya +Matthew Mglej Is there any possibility we can draft and send email after this step without using CDO message in VBA.

    • Maheswaran K
      Maheswaran K 3 years ago

      +Anita Mallya Thank you. It is working fine now

    • Anita Mallya
      Anita Mallya 3 years ago

      +Maheswaran K I just checked step by step even for new Gmail Site in which Next button is presented after we programmatically put in the Login. I was successful in first programmatically putting my user id and then programmatically clicking on Next button and then programmatically keying in the password and then programmatically clicking in SignIn button. Google allowed me to sign in but quickly detected that the Sign in is from a automated system and simply blocked me from going further and told me to use the Recovery Process to log in . That is, in Recovery Process they ask us to fill Recovery Email address. If you have not yet given them your Recovery Email address for your Account please do not try to programmatically log in as you might lose access to your account permanently because of this programmatic login.

  • Karan Garg
    Karan Garg 3 years ago

    Hi Dinesh,
    The tutorials are really helpful and I was able to get whatever I was looking for. Thanks a lot for that.
    While working I came across few questions. Please help me out if you'd be able to.
    I am looking to extract the data from website that has a login page using a VBA Code.
    So first I would need to run a program to login to the page.
    ru-clip.net/video/kdD2bb4DU6c/video.html (This Video)
    And then I would need to extract the data from the website.
    ru-clip.net/video/qbOdUaf4yfI/video.html (Your Data Scrapping Video)
    I have both the programs ready with me because of your videos help. :)
    But when I am trying to login. It logs in through the web browser. I am looking to login within the query as only then I would be able to look inside the data. Please could you help me out with this. It would just require a small change I guess in the Login Code.
    Also I have a workplace desktop and a laptop at home. I wanted to know if there any setting involved for the data scrapping. At my workplace I am being able to extract the data table by table by selecting a particular table and clicking on Import. Whereas at my home I can only extract the full data where as I want to extract only one table for the same website.
    Please help if you can. Looking for a response.
    Thanks,
    Karan Garg

  • prince jain
    prince jain 3 years ago

    Hello Dines,
    I am trying to automate a bank site using excel VBA macro in my project environment.
    But facing this issue" The object has disconnected from its client"

    I google out for solution. I got to know that its due to security or zone related issue in project environment. So I tried to change security tab in internet option . But not able to change because i do not have admin rights to do this.
    I have also tried used below three types of liens to create IE object. But not able to resolve this issue.
    Set IE = New InternetExplorerMedium
    Set IE = New InternetExplorer
    Set IE = CreateObject("InternetExplorer.Application")

    Please guide me to solve this issue.

  • Joe Test
    Joe Test 3 years ago

    This is a very thorough and useful tutorial. Although I have made a modest attempt to understand some of these methods, I'm afraid the new gmail format that prompts you to enter a username in one screen, click "next", then enter the password in the next page, then click submit (preferably with the "stay signed in" input box unchecked) does not seem to work with this code.Any update or guidance is appreciated.

    • manthena143
      manthena143 2 years ago

      Could you please provide the code to login as ealier code not working properly

    • Dinesh Kumar Takyar
      Dinesh Kumar Takyar  3 years ago

      +Joe Test This time you'll have to log-in step by step. The coding remains almost the same!

  • MUSTAFA BAKKAL
    MUSTAFA BAKKAL 3 years ago

    mr. dinesh somesite has javascript code how to loging website which has javascrip. thx for your kindly reply

  • Prasad0812
    Prasad0812 3 years ago

    Just simply what I was looking for. This is great! Thank you Dinesh.

  • Jorge Eduardo Gomez
    Jorge Eduardo Gomez 3 years ago

    Great Video! Thanks A lot for the info!

  • Nathaniel Tyler
    Nathaniel Tyler 3 years ago

    Can you do a tutorial on making PDFs in Adobe Acrobat pro while using vba to create a navigational bookmark pane for pdf about to be generated? Furthermore can you explain nodes and the objects necessary to preform this task?

  • Ranjeet Bisht
    Ranjeet Bisht 3 years ago

    hallow sir how can we go same as for drop down list

  • Mayur Sapre
    Mayur Sapre 3 years ago

    Only web page is opening,inputs are not taking

  • Matthew Gohr
    Matthew Gohr 3 years ago +1

    Hello,
    Thanks for the amazing video!! Your amazing!

  • Rajnish Dubey
    Rajnish Dubey 3 years ago

    Very nic Sir. I will try this today . IF any error will get back here again.

  • Zoey Nguyen
    Zoey Nguyen 3 years ago

    Thank you so much for this video! It helps me create my first VBA with HTML.
    Could you please help me with the inputs for this link: solutions.caqh.org/bpas/Default.aspx?ReturnUrl=%2fbpas%2fdefault.aspx%2f
    I tried to log in but may be i used the wrong "name" or ID.