Sharid
Well-known Member
- Joined
- Apr 22, 2007
- Messages
- 1,066
- Office Version
- 2016
- Platform
- Windows
Hi
Could somebody please help me,
The following code is should navigate to google and then pull all the urls from the link to a sheet. I keep having issues with the line of code shown in red. "Object doesn't support this property or method"
Thanks for having a look
Could somebody please help me,
The following code is should navigate to google and then pull all the urls from the link to a sheet. I keep having issues with the line of code shown in red. "Object doesn't support this property or method"
Code:
Sub webpage()
Dim internet As Object
Dim internetdata As Object
Dim div_result As Object
Dim header_links As Object
Dim link As Object
Dim URL As String
Set internet = CreateObject("InternetExplorer.Application")
internet.Visible = True
URL = "https://www.google.co.in/search?q[COLOR=#000000]=how+to+program+in+vba"[/COLOR]
internet.Navigate URL
Do Until internet.ReadyState >= 4
DoEvents
Loop
Application.Wait Now + TimeSerial(0, 0, 5)
Set internetdata = internet.Document
Set div_result = internetdata.getElementById("res")
Set header_links = div_result.getElementsByTagName("h3")
For Each h In header_links
Set link = h.ChildNodes.Item(0)
'Cells(Range("A" & Rows.Count).End(xlUp).Row + 1, 1) = link.href
Set internetdata = internet.Document
Set internetdatalink = internetdata.getElementById("rso")
Set internetlink = internetdatalink.getElementsByTagName("h3")
For Each texttext In internetlink
[COLOR=#ff0000] ActiveSheet.Cells(i, 2).Value = texttext.href[/COLOR]
i = i + 1
Next texttext
Next
MsgBox "done"
End Sub
Thanks for having a look