Search OuterText or OuterHTML

Posted on 2006-04-07
Last Modified: 2010-05-18
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,
Question by:John Account
    LVL 28

    Accepted Solution

    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
    LVL 28

    Expert Comment


    Author Comment

    by:John Account
    Thanks, vinnyd79.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Join & Write a Comment

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now