I encounter error when running my Excel Macro VBA. It says: Object variable or With block variable not set
Private Sub CommandButton1_Click()
Dim ie As InternetExplorer
Dim doc As HTMLDocument
Dim rating As String
Set ie = New InternetExplorer
With ie
.navigate "https://www.pse.com.ph/company-information-JFC/"
.Visible = False
Do While .readyState <> 4: DoEvents: Loop
Set doc = ie.document
With doc
rating = .getElementsByClassName("last-price")(0).PreviousSibling.getElementsByTagName("h3")(0).innerText
MsgBox rating
End With
End With
ie.Quit
End Sub
Excel points me here:
rating = .getElementsByClassName("last-price")(0).PreviousSibling.getElementsByTagName("h3")(0).innerText
I browse through Microsoft documentations. They're telling that my variable was not set. Though at first glance, my code looks fine.
Please advise.