+ Reply to Thread
Results 1 to 4 of 4

Web query with QueryTables

  1. #1
    Registered User
    Join Date
    05-30-2009
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    4

    Web query with QueryTables

    Hello,
    I am having problems getting to work a web query in a VBA macro. The goal is simply to get a value retrieved from a web query into an excel cell.

    The below code works well with standard html pages (like replacing the url with www.google.com). However, the page I want to retreive (a query at geonames.org that retreives an altitude value for given lattitude/longitude values) does not contain any HTML headers, but just a number in plain text. In this case the below query does not returns anything. I tried different formating options for the query but up to nownothing works. Any idea how to solve this ? Thanks in advance !


    Please Login or Register  to view this content.
    Last edited by fredoman; 06-03-2009 at 06:16 PM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Web query with QueryTables

    Try using IE automation and the HTML DOM, like this:
    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-30-2009
    Location
    France
    MS-Off Ver
    Excel 2003
    Posts
    4

    Re: Web query with QueryTables

    Thanks a lot, your code definitive works. I hope it's reasonably fast since I will have typically 200-1000 lookups to do, maybe I will have to play around a bit. In any case I have a good starting point now.

  4. #4
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Web query with QueryTables

    Yes, it should be reasonably fast. For multiple lookups, put the CreateObject and .Quit outside any loop, so that the IE object is created and destroyed only once. For faster performance you could try the WinHttpRequest object instead of InternetExplorer because IE is an unnecessary overhead for what you're doing (getting data from a web page with no need for the visual element that IE can provide).

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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