Got error while extracting Bing RSS results

satish78

Board Regular
Joined
Aug 31, 2014
Messages
218
After long time, VBA code is not working properly today.
Got run-time error '1004':application-defined or object-defined error

When I clicked Debug
It showed me at Sheet1.Cells(rCount, ItemIndex + 1).Value = Node.nodeTypedValue

I think Bing changed its fields, do not know exactly.

Here is the code

Dim rCount As Long
Public Sub GetDataFromBing(ByVal strurl As String)
Dim xDOC As DOMDocument
Dim XMLHttpRequest As XMLHTTP
Dim response As String
Dim URL As String
Dim sTemperature As String

'URL = "http://www.bing.com/search?q=Aaron%20BentDirector%20Business%20Development%20at%20Analyze%E2%80%A6locationindustry&qs=&format=rss"
URL = strurl
Set XMLHttpRequest = New MSXML2.XMLHTTP
With XMLHttpRequest
.Open "GET", URL, False
.send
End With

Set xDOC = New DOMDocument

Do Until xDOC.readyState = 4
Loop
xDOC.LoadXML (XMLHttpRequest.responseText)
Set xNode = xDOC.SelectSingleNode("//channel")

If Not xNode Is Nothing Then
Dim strValue As String

For FieldIndex = 1 To xNode.ChildNodes.Length
If FieldIndex > 5 Then
Set items = xNode.ChildNodes(FieldIndex)
If Not items Is Nothing Then
For ItemIndex = 0 To items.ChildNodes.Length - 1
Set Node = items.ChildNodes(ItemIndex)
Sheet1.Cells(rCount, ItemIndex + 1).Value = Node.nodeTypedValue
Next ItemIndex
End If
rCount = rCount + 1
End If
Next FieldIndex
Else
rCount = rCount + 1
End If


On Error Resume Next


End Sub


Public Sub loadURL()
Dim sh As Worksheet
Dim rw As Range
Dim RowCount As Long


RowCount = 0
rCount = 3
Set sh = ActiveSheet
For Each rw In sh.Rows
If RowCount >= 2 Then
If sh.Cells(rw.Row, 1).Value = "" Then
Exit For
Else
GetDataFromBing sh.Cells(rw.Row, 1).Value

End If
End If



RowCount = RowCount + 1


Next rw


MsgBox (RowCount - 2)
End Sub
 
Last edited:

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Forum statistics

Threads
1,223,910
Messages
6,175,318
Members
452,634
Latest member
cpostell

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top