Consulting

Results 1 to 3 of 3

Thread: Http - stumbling block

  1. #1
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location

    Http - stumbling block

    As part of a larger project to create spreadsheets with pricelists for publications from various sources, using a huge Title/ISBN Access lookup the goal was to use the WinHttp.WinHttpRequest.5.1 ActiveX Object which comes with XP and 2000. An alternative would be MSXML2.XMLHTTP.4.0 but that appears to require a separate download and install. The below code illustrates a problem (URL is hard-coded for the example) with 5.1 - curious 5.1 does not include a ResponseXML.xml property - which MSXML2 has, though not needed to work. Can anyone suggest a way to get 5.1 to return a response without error? TIA Stan


    Sub HttpRequest()
    Dim oHTTP, cURL
    cURL = "http://www.chapters.indigo.ca/item.asp?"
    cURL = cURL & "Catalog=books&Item=978089957726"
     
    'test Http GET request with 2 Microsoft Objects
    'should return results if run as is with MSXML - but
    'try it with 5.1
     
    'uncomment the WinHttp Object for Unicode error
    'Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
     
     
    'comment next line if testing for unicode error
    Set oHTTP = CreateObject("MSXML2.XMLHTTP.4.0")
     
    'same code - either object
    oHTTP.Open "GET", cURL, False
    oHTTP.SetRequestHeader "Content-Type", "text/xml"
    oHTTP.Send ""
    MsgBox oHTTP.ResponseText
    oHTTP = 0
    End Sub

  2. #2
    Administrator
    VP-Knowledge Base
    VBAX Grand Master mdmackillop's Avatar
    Joined
    May 2004
    Location
    Scotland
    Posts
    14,489
    Location
    Hi Stan
    This is a bit beyond me in any case, but when I tried to run the code, it appears I'm missing a reference. What references do you have running?
    MD
    MVP (Excel 2008-2010)

    Post a workbook with sample data and layout if you want a quicker solution.


    To help indent your macros try Smart Indent

    Please remember to mark threads 'Solved'

  3. #3
    VBAX Master stanl's Avatar
    Joined
    Jan 2005
    Posts
    1,141
    Location
    Thank you for your interest. I attached a screenshot of my refs, though I wonder if it might not be an issue with Objects being registered. If you do get it to work, the URL should give back a response that the requested book could not be found - but you will notice the error is in French and English - which is where I suspect the Unicode error comes in. Substitute this URL:

    cURL="http://www.chapters.indigo.ca/item.asp?"
    cURL= cURL & "Item=978047174048&Catalog=Books&N=35+528447&Lang=en&Section=books&zxac=1"
    Which is a book on Federal Audits. The data of interest would be parsing the classcode for "ourprice"

    <tr>
    <td class="ourprice">Our Price:</td>
    <td class="ourprice">$97.99</td>
    </tr>
    Stan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •