none
Write text into textbox on website with VBA RRS feed

  • Question

  • Hello guys!

    I would like to collect infromation from a website, but it gives the segmented information only if i search for the city or town then I press the submit button. I cannot figure out how to set a value on the website. My code is below! Any tips are appriciated, thanks!

        Dim IE As Object
        Dim objElement As Object
        Dim objCollection As Object
     
        ' Create InternetExplorer Object
        Set IE = CreateObject("InternetExplorer.Application")
        IE.Visible = True

        IE.Navigate "givenwebsite.com"

        ' Wait while IE loading...
        Do While IE.Busy
            Application.Wait DateAdd("s", 1, Now)
        Loop
     
        ' HTML
        '   1. Text field
        '   <input name="term" id="map_cim_search" type="text">
        '   2. Button
        ' '<input class="submit" id="b90feb8ef74e087c31230a4bfb8c27af5b310628" type="submit" value="">
        'Set ObjCollection = ie.Document.getElementsByName("user_numbers.1.number_1").Value = "123"
        
          IE.document.getElementsById("map_cim_search").Value = "London"
        Application.Wait (Now + TimeValue("0:00:03"))
        IE.document.getElementsById("b90feb8ef74e087c31230a4bfb8c27af5b310628").Click

    Friday, March 31, 2017 12:07 PM

All replies

  • A LOT depends on the page itself, but this kind of code has worked for me - you need to have some form of 'pressing enter' which the submit method does for you:

        With IE
            .Document.all.Item("Name").Value = "Joe Excel"
            .Document.all.Item("Password").Value = "PleasePleaseWork"
            .Document.forms(0).submit

        End With


    Friday, March 31, 2017 5:29 PM