patriciaxxx
Programmer
I have the following sub, which should connect to ebay and output the following in the Immediate Window
US $2.55
No Data
US $6.50
But when I run it all I get is error With block or variable not set. I’m using winXP, Access 2003. I have no special references set and the code compiles successfully. I have checked the help and internet for the error but can’t seem to work out the problem.
US $2.55
No Data
US $6.50
But when I run it all I get is error With block or variable not set. I’m using winXP, Access 2003. I have no special references set and the code compiles successfully. I have checked the help and internet for the error but can’t seem to work out the problem.
Code:
[COLOR=#204A87]Option Compare Database
Option Explicit
Sub xmlHttp()
Dim x As Integer
Dim URl As String
Dim objShipping As Object
Dim divShip As Object
Dim xmlHttp As Object
Set xmlHttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
Dim ITEM_NUMBER_ARRAY As Variant
ITEM_NUMBER_ARRAY = Array("290941626676", "130942854921", "400035340501")
For x = 0 To UBound(ITEM_NUMBER_ARRAY)
''Here is your URL
URl = "[URL unfurl="true"]http://www.ebay.com/itm/"[/URL] & ITEM_NUMBER_ARRAY(x) & "?ru=http%3A%2F%2F[URL unfurl="true"]www.ebay.com%2Fsch%2Fi.html%3F_from%3DR40%26_sacat%3D0%26_nkw%3D"[/URL] & ITEM_NUMBER_ARRAY(x) & "%26_rdc%3D1"
xmlHttp.Open "GET", URl, False
xmlHttp.setRequestHeader "Content-Type", "text/xml"
xmlHttp.send
Dim html As Object
Set html = CreateObject("htmlfile")
html.body.innerHTML = xmlHttp.ResponseText
Set objShipping = html.getelementbyid("shippingSection").getElementsbytagname("td")(0)
If Not objShipping Is Nothing Then
Set divShip = objShipping.ChildNodes(1)
Debug.Print divShip.innerHTML
Else
Debug.Print "No Data"
End If
Next
End Sub[/color]