shahin
Active Member
My script is supposed to parse some information from a webpage and it is doing fine to some extent. However, it throws an error "Object variable or with----" when the item I'm looking for is not available in that page.
Few days back while dealing with a similar problem I got stuck. Narayan gave me a solution then to get rid of that. For some weird reason the same solution is not working here. Perhaps there is any trick of it's usage I don't understand.
Btw, I've searched for few items using inputbox search in a webpage. When I hit the search button and any search is not a match, it leads me to another page. The above error I'm having when my browser leads me to another page.
I can get rid of that If I wish to do something like below but I wanna be stick to any conditional statement to fix the error I'm having.
Few days back while dealing with a similar problem I got stuck. Narayan gave me a solution then to get rid of that. For some weird reason the same solution is not working here. Perhaps there is any trick of it's usage I don't understand.
Code:
Set post = html.getElementsByClassName("data")(2).getElementsByTagName("th")
If Not post Is Nothing Then '''tried with "If Not post(0) Is Nothing" as well
cel.Offset(0, 2) = post(0).innerText
End If
Btw, I've searched for few items using inputbox search in a webpage. When I hit the search button and any search is not a match, it leads me to another page. The above error I'm having when my browser leads me to another page.
I can get rid of that If I wish to do something like below but I wanna be stick to any conditional statement to fix the error I'm having.
Code:
On Error Resume Next
Set post = html.getElementsByClassName("data")(2).getElementsByTagName("th")
cel.Offset(0, 2) = post(0).innerText
On Error GoTo 0
Last edited: