Detect when Word is trapped with a partial wildcard match at the very end of a document

Article contributed by Bill Coan

SearchString(0) = "\<\<"
SearchString(1) = "\<[!>]@\<"
SearchString(2) = "\>\>"
SearchString(3) = "\>[!<]@\>"

For i = 0 To 3
    Selection.HomeKey unit:=wdStory

     'call subroutine that clears settings from find dialog
    Call ClearFindAndReplaceParameters

    With Selection.Find
        .Text = SearchString(i)
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = True
        .MatchSoundsLike = False
        .MatchAllWordForms = v
    End With

    Do While Selection.Find.Execute()
        'here's where we detect the fact that
        'Word got lost at the end of the doc
   If Selection.End = 0 Then Exit Doo
       'insert code here to act on found text
    Selection.Collapse wdCollapseEnd

Next i