Search OuterText or OuterHTML

Using the browser control, sometimes a link renders error 404, page not found. I would like to know when this happens so as to respond accordingly. So, I ask you, Expert, what's the best way to search for the text "The page cannot be found"?

Many thanks in advance,
John
John AccountAsked:
Who is Participating?
 
vinnyd79Commented:
You can use instr :

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As Variant)
Dim strText As String
strText = WebBrowser1.Document.documentelement.outertext
If InStr(strText, "No page to display") > 0 Then
        MsgBox "No Page"
ElseIf InStr(strText, "The page cannot be displayed") > 0 Then
        MsgBox "No Page"
End If
End Sub
0
 
John AccountAuthor Commented:
Thanks, vinnyd79.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.