Automating the Internet Explorer Web Browser (Entering Text and Clicking Button)

Share
Embed
  • Published on Apr 17, 2012
  • Automating InternetExplorer.Application to enter text into field, clicking a button and waiting for a page to load. Code used:
    Set objIE = CreateObject("InternetExplorer.Application")
    objIE.Top = 0
    objIE.Left = 0
    objIE.Width = 800
    objIE.Height = 600
    objIE.AddressBar = 0
    objIE.StatusBar = 0
    objIE.Toolbar = 0
    objIE.Visible = True 'We will see the window navigation

    objIE.Navigate ("www.bestbuy.com")
    Do
    DoEvents
    Loop Until objIE.ReadyState = 4
    In this video the .Navigate and .ReadyState options for the control are used along with using a Range as your input for the URL web page.
  • Howto & StyleHowto & Style

Comments • 43

  • Brandon Redmond
    Brandon Redmond Month ago

    5:53 Hey! Dont tell mom, the babysitter's dead!
    EDIT: Oh, you revealed the source at the end of the video. Well, i guess i dont look as smart anymore. But if it matters, im sure the line is "the dishes are done, man"

    • Brandon Redmond
      Brandon Redmond Month ago

      +Alex C Thanks again!

    • Alex C
      Alex C  Month ago

      +Brandon Redmond API is just (Application Program Interface). By definition, API is "a set of functions and procedures allowing the creation of applications that access the features or data of an operating system, application, or other service." Microsoft developed an API for Windows, that enabled developers to control windows, menus and their controls. Windows API can be utilized through C# or VB.NET (ASP.NET), C++, Visual Basic..and this is just to name a few. Programming in C# will require Visual Studio. If your resources are limited, start with Microsoft Excel VBA, as that only requires having Microsoft Excel. VB6 syntax is usually the same. Have fun! :)

    • Brandon Redmond
      Brandon Redmond Month ago

      +Alex C Thank you very much for the reply. So it sounds like if i become nimble with Visual Basic 6.0 independently, i can then just kinda figure out how to apply it to VBA? I think I will try that. Also, I encountered something about .NET, which i have heard of before and i believe it is necessary to run C# which is out of the scope of what we are really talking about. I only bring it up because i wonder if learning whatever .NET is will help me with API stuff. I have found a lot of stuff on youtube on automating for internet browsers, now that you mention it. I think what i am missing is automating third-party programs running locally.

    • Alex C
      Alex C  Month ago

      +Brandon Redmond I would say do a google search for "api windows VB6" - Visual Basic 6.0 syntax is for the most part exactly the same as VBA. There are some instances where you need to make modifications. VB 3.0 to VB 6.0 for me was an AOL Era. At the time, chat room programs were very popular, and got me started with Windows API back in 1996. That being said, I know there are many forums still online showcasing Windows API and VB6 examples as this was an incredibly popular topic in those days - and you can the VB6 code you find in VBA. As far as automating web, there are several tutorials online. You're typically going to find the most up to date resources on the internet.

    • Brandon Redmond
      Brandon Redmond Month ago

      +Alex C No worries! Anyway, while I got your attention, can I ask how you learned this kind of stuff with VBA? I mean automating a website and using the API to automate external windows. I really really want to learn this in the worst way. Can you recommend books or do plan to make more videos on this subject?

  • GetGamingChris
    GetGamingChris 2 months ago

    How do you read text and store it?

  • YASHU DHINGRA
    YASHU DHINGRA 6 months ago

    Can you plz help me to add phone numbers in website using macro

  • Shariq Khan
    Shariq Khan 9 months ago

    Hello Alex, I am having a hard time with www.yyc.com/en-us/travellerinfo/flightinformation/flightschedule.aspx. once the website loads I am trying to click on the tomorrow button but it doesn't have an ID that works and the web address doesn't change if I click on tomorrow so not sure how I could work this out! Any help would be great! thanks.

  • fernando sandoval

    can you help how to press accept buttons on a specific website for appointments for my work i am willing to pay you some money

  • Do you know about This?

    Hi thanks for amazing videos could you please help me to how to click on Radio button using vba in internet explorer, please check below link for radio button.
    www.w3schools.com/html/tryit.asp?filename=tryhtml_form_radio

  • Anirban Das
    Anirban Das Year ago

    Hi, thanks for the video.. I have a need to pass a value from the excel to the input field, so instead of "bose radio" can i reference it to a cell value like IE.document.GetElementbyID("username") = Sheets("Sheet1").Range("K7")?
    I keep getting an error that the "Interface is Unknown".
    Kindly suggest.

    • The King Of Mystery
      The King Of Mystery 11 months ago +1

      Use, this: document.querySelector(".SB");

    • fUjiMaNia
      fUjiMaNia 11 months ago

      The LOGIN(submit) button on the page I'm trying to do this one doesn't have an ID, there is only Type & Class in the code so how do I click the button? I'm trying the equivalent to his ("SB").click section.

    • The King Of Mystery
      The King Of Mystery Year ago

      Try using .value
      IE.document.GetElementByID("username") = Sheets("Sheet1").Range("K7")
      or this:
      IE.document.GetElementByID("username").value = Sheets("Sheet1").Range("K7")

  • Calzoners
    Calzoners Year ago

    what language is this in?

  • Packing Karo
    Packing Karo 2 years ago

    how to open browser in full screen when perform this action?

  • K T
    K T 2 years ago

    Sub open_click()
    Set objIE = CreateObject("Firefox.Application")
    objIE.Navigate ("www.google.com")
    End Sub
    I'm getting Run-time error '429': Set objIE = CreateObject("Firefox.Application") - is highlighted in yellow, where is the mistake?

    • Jaden Williams
      Jaden Williams Year ago

      Don't use firefox. What do you think IE stands for? Internet Explorer ;D

    • Packing Karo
      Packing Karo 2 years ago

      i also got this error

  • Amit Bodhwani
    Amit Bodhwani 2 years ago

    Hi,
    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

  • Jacob Jones
    Jacob Jones 2 years ago

    I cannot for the life of me find the video that tells how to make the InternetExplorer.Application thing work. He said he has an earlier video, but I can't find it. Can someone help?

  • Chris Brocious
    Chris Brocious 2 years ago

    Are people still writing in VB or is it .Net now?

  • Darren Allen
    Darren Allen 2 years ago

    Hi Alex,
    I dont have a button name on the following .



    how do i click the search button ?

  • planezero
    planezero 3 years ago +3

    More changes to the site - this now works for me (May 2016):
    objIE.document.getElementById("gh-search-input").Value = "bose radio"
    Set ButtonReturned = objIE.document.getElementsByClassName("search-button")
    For Each Button In ButtonReturned
    Button.Click
    Next Button

    • planezero
      planezero 2 years ago

      You're welcome, I dont remember how I got there at the time but googling "html object library" will give you a ton of related info. First hit gives you the different getElementsBy methods ..

    • Kemal Talen
      Kemal Talen 2 years ago

      Thanks for the help! I couldn't find getElementByClassName in the Microsoft documentation... how did you know it was supported?

  • zummo TV
    zummo TV 3 years ago +2

    how websites detect automation?

    • Nicolás da Silva Santamaria
      Nicolás da Silva Santamaria 2 years ago

      I was wondering the same. Perhaps they would detect the number of iterations (e.g. clicks, requests sent) etc. and would work out what is re reasonable number of iterations.
      Other than that, I wouldn't know

  • satish hurjal
    satish hurjal 3 years ago

    Thanks Alex...realy nice video

  • Tyson Price
    Tyson Price 3 years ago

    wow you are the man!I have a question....so far everything works except the part where the data is entered into the input box on the webpage, do you have any suggestions?does this work the same for a localhost page?

  • Riza Khan
    Riza Khan 3 years ago

    You are god.

  • viraj pandya
    viraj pandya 3 years ago

    hi
    alex
    nice video
    i want to do something similar to this to the enquires i recieve in my b2b portals is to reply to the enquires with thier respective prices (templates) is it possible ?

  • cavan constan-tatos
    cavan constan-tatos 3 years ago

    Thanks Alex - you explain things really well and don't take overlook the fact that many of us out here are utter novices. I've been trying to fill in some boxes on a website and the click on a button, but the source code was intimidating me. I like how you showed how to look at it and explained briefly what it means... so I'll give my code another bash now

  • Scarlet Leaner
    Scarlet Leaner 4 years ago

    Great! Alex Well Done, Very Useful to me, Thanks for Uploading

  • Ed Carranza
    Ed Carranza 4 years ago

    Since I tried this on 8/9/14, I guess bestbuy changed some of the source code. The following worked for me.
    objIE.document.getElementById("search-field").Value = "bose radio"
    objIE.document.getElementById("search-button").Click
    Video was very helpful. Thanks

  • Frank Turley
    Frank Turley 5 years ago

    Thanks Alex, another great video

  • Tadas Vaitkevičius
    Tadas Vaitkevičius 5 years ago

    hi i get runtime error 429 activex component cant create object . any help ?

  • Sheldon Brooks
    Sheldon Brooks 5 years ago +1

    im looking for a tutorial that shows the basics of using vba to navigate internet explorer. Can anyone point me in the right direction.
    Thanks

  • Victor J
    Victor J 5 years ago

    you are the best! thanks very useful

  • Ivan Naux
    Ivan Naux 6 years ago

    Thank you! It's like pulling teeth to find this on forums.

  • Alvord1430
    Alvord1430 6 years ago

    My webpage has frames. I think the fact it has frames is not allowing me to get to the button that I need to .Click.