Hi , I'm currently trying to extract the title and dates of each news article in my url range by finding the h1 class "headline node- title" and getting the title based on it.
When I try running my code, I get [object HTMLHeadingElement] instead of the title "No new curbs in recent wave..." . Any solution on how to fix it? Here is one of the website I use No new curbs in recent wave, but they cannot be ruled out if new nasty Covid-19 variant hits: Ong Ye Kung
Here is my code :
When I try running my code, I get [object HTMLHeadingElement] instead of the title "No new curbs in recent wave..." . Any solution on how to fix it? Here is one of the website I use No new curbs in recent wave, but they cannot be ruled out if new nasty Covid-19 variant hits: Ong Ye Kung
Here is my code :
VBA Code:
Private Sub CommandButton5_Click()
Dim URL As String, IE As Object, Count As Integer
Set s1 = Worksheets("Sheet1")
Set IE = CreateObject("InternetExplorer.Application")
IE.Visible = True
Range("A2").Select
Count = 2
While ActiveCell.Value <> ""
URL = ActiveCell.Value
If Count >= 1 Then
IE.Navigate URL
End If
Do While IE.ReadyState = 4: DoEvents: Loop
Do Until IE.ReadyState = 4: DoEvents: Loop
Set ieClassColl = IE.document.body.getElementsByClassName("headline node-title")
s1.Cells(Count, "B") = ieClassColl
Count = Count + 1
ActiveCell.Offset(1, 0).Select
Wend
If ActiveCell = "" Then
IE.Quit
End If
On Error GoTo AppQuit
AppQuit:
MsgBox "Application Closed"
End Sub