+ Reply to Thread
Results 1 to 5 of 5

Question re. pulling HTML into Excel

  1. #1
    Registered User
    Join Date
    03-20-2012
    Location
    Washington D.C.
    MS-Off Ver
    Excel 2007
    Posts
    1

    Question re. pulling HTML into Excel

    Greetings,

    I am relatively new to VBA programming. I am trying to pull some information from google maps. I would like to use the following VBA function:

    Private Function WebResponse(sURL As String) As String

    Dim XmlHttpRequest As Object
    Set XmlHttpRequest = CreateObject("MSXML2.XMLHTTP")
    XmlHttpRequest.Open "GET", sURL, False
    XmlHttpRequest.send
    WebResponse = XmlHttpRequest.responseText

    End Function

    I have this function in a module right now.

    The following is in A1:
    http://maps.google.com/maps?f=d&sour...on,+D.C.&hl=en

    I type "=WebResponse(A1)" in A2 and Excel returns "#VALUE!".

    The URL is functioning in my browser. I have tried to use this function on other working URLs as well but they all throw the same error.

    Help would be much appreciated!! Thanks in advance.

    Nick

  2. #2
    Valued Forum Contributor
    Join Date
    03-14-2012
    Location
    Arizona USA
    MS-Off Ver
    Excel 2000/2007
    Posts
    408

    Re: Question re. pulling HTML into Excel

    What type of data are you trying to capture?

  3. #3
    Registered User
    Join Date
    08-09-2011
    Location
    london,england
    MS-Off Ver
    Excel 2007
    Posts
    10

    Re: Question re. pulling HTML into Excel

    Normally these type of queries are REST queries which would be returning json or XML structured data, as opposed to some kind of formatted web page.

    There is a library here specifically to deal with excel.rest integration http://ramblings.mcpher.com/Home/excelquirks/json/rest

    google maps .. Assuming you are doing a query.. Is a specific type of rest query.. You can also generate JavaScript straight out of excel to map excel data using the information and downloads you will find here.

    http://ramblings.mcpher.com/Home/excelquirks/getmaps

  4. #4
    Registered User
    Join Date
    03-21-2012
    Location
    US
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Question re. pulling HTML into Excel

    Hey guys, Try this blog it tell you how to convert html to pdf : http://tom101224.weebly.com/5/post/2...ml-to-pdf.html, or you may need a third-party tools.

  5. #5
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Question re. pulling HTML into Excel

    The problem is likely to be that you haven't given time for the website to return the data before trying to return the result to the function. This causes an error.

    After your .send, insert this line of code:
    Please Login or Register  to view this content.
    Additionally, I highly suspect that this won't return what you expect

+ 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