+ Reply to Thread
Results 1 to 8 of 8

Pass textbox value to google search to look up post code

  1. #1
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Pass textbox value to google search to look up post code

    Hi All
    Has anyone an example or pointer to a method of passing an Eirecode value (postcode) from a userform textbox click event that will open explorer or chrome and search for the parameter passed from textbox. I am wondering if this is possible as an aid to route planning

    any ideas appreciated
    Last edited by nigelog; 09-07-2020 at 05:08 AM.

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Pass textbox value to google search to look up post code

    use the followhyperlink method in code attached to the click event. more than likely that will do what you need. be aware though, that the method I've just mentioned will open the browser that you have set as default. you don't have a choice. as far as passing the value from the box to a webpage HTML element, you have to use code to do it because Excel's interface commands and menus can't do stuff like that. it has no connection to browser programs, I don't believe, other than powerquery, which can query webpage HTML tables and stuff.

    if you use the IE object in VBA code, you can do this by using the DOM (document object model) and writing javascript commands. for instance:
    Please Login or Register  to view this content.

  3. #3
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Pass textbox value to google search to look up post code

    Thanks for answer I'Ll dig further

  4. #4
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Pass textbox value to google search to look up post code

    I don't recommend using event trigger on textbox. If you must, may be use Exit event.

    But in general, it's safer to use CommandButton or other means to trigger action.

    Ex:
    Please Login or Register  to view this content.
    In Standard module.
    Please Login or Register  to view this content.
    As previous poster alluded to. Reading contents of browser can be bit more tricky. And since IE is at end of life (support ends in Mar 2021)...

    You may be better off using Selenium Wrapper for VBA. Though I have no experience with that.
    ?Progress isn't made by early risers. It's made by lazy men trying to find easier ways to do something.?
    ― Robert A. Heinlein

  5. #5
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Pass textbox value to google search to look up post code

    Quote Originally Posted by CK76 View Post
    Please Login or Register  to view this content.
    I have always found the .readystate and .busy are both extremely unreliable. I tested both of them along time ago, and have never liked either of them.

  6. #6
    Forum Expert CK76's Avatar
    Join Date
    06-16-2015
    Location
    ONT, Canada
    MS-Off Ver
    MS365 Apps for enterprise
    Posts
    5,913

    Re: Pass textbox value to google search to look up post code

    It's usually a must when you interact with IE or browser.

    Alternate approach, if you are certain of the site/page structure and know the element that will hold value that you are after (which could be filled via javascript, Ajax, etc).

    Then you can check until element is present, or check that it matches expected pattern.

    Piloting browser is always going to be unreliable when compared to using web request directly (XMLHTTP, WINHTTP etc). However, it's necessary for scraping site that generates content via script/code.

    For geocode, map, route etc. I prefer to leverage API. But depending on use case, API may not be suitable. There's always more than one way to solve problems. It's just matter of what approach best suites your particular need.

  7. #7
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: Pass textbox value to google search to look up post code

    Quote Originally Posted by CK76 View Post
    There's always more than one way to solve problems. It's just matter of what approach best suites your particular need.
    no argument.

  8. #8
    Forum Expert nigelog's Avatar
    Join Date
    12-14-2007
    Location
    Cork, Ireland
    MS-Off Ver
    Office 365 Windows 10
    Posts
    2,286

    Re: Pass textbox value to google search to look up post code

    @CK76
    thankyou, in this instance seems to work ok from a command button search.

+ 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. Replies: 0
    Last Post: 09-06-2018, 07:41 PM
  2. [SOLVED] Vba assistance with UserForm Textbox search code
    By sintek in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-05-2016, 09:02 AM
  3. [SOLVED] Show Textbox Title inside the TextBox like Google
    By AmirSoft in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-29-2015, 05:30 AM
  4. Replies: 3
    Last Post: 10-23-2012, 06:09 AM
  5. Userform: Pass textbox values to another textbox on button press
    By adjustermn in forum Word Programming / VBA / Macros
    Replies: 3
    Last Post: 02-09-2010, 11:19 PM
  6. Replies: 0
    Last Post: 11-05-2009, 04:47 AM
  7. [SOLVED] Search Google from Textbox
    By John in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-13-2005, 11:05 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