stanl
10-22-2005, 07:05 AM
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
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