MiDocSearch Object

MiDocSearch

Provides methods for searching the recognized text in a document.

Using the MiDocSearch Object

Use the Initialize method to prepare the MiDocSearch object for a subsequent call to the Search method by supplying the document and page to search, the word or phrase to search for, and additional search settings. The Search method returns an IMiSelectableItem object, which exposes a Words collection. By using this collection, you can access the Count of found words and, through each individual Word object, the coordinates of the bounding rectangle that defines its location on the page.

Example

The following example initializes and runs a search of the recognized text of the first page in the document for the word or phrase entered in a textbox, txtSearch, and then displays the results.

Sub TestSearch()
  
  Dim modiDoc As MODI.Document
  Dim modiSearch As MODI.MiDocSearch
  Dim modiTextSel As MODI.IMiSelectableItem
  Dim strSearchInfo As String
  
  ' Load an existing TIFF file.
  Set modiDoc = New MODI.Document
  modiDoc.Create "C:\document1.tif"
  
  ' Perform OCR.
  modiDoc.Images(0).OCR
  
  ' Search for the selected word.
  Set modiSearch = New MODI.MiDocSearch
  modiSearch.Initialize modiDoc, txtSearch.Text, 0, 0, False, False
  modiSearch.Search Nothing, modiTextSel
  
  ' Display search results.
  If modiTextSel.Words.Count > 0 Then
  strSearchInfo = "The search found " & _
    modiTextSel.Words.Count & _
    " instances of the search word(s)."
  Else
   strSearchInfo = "Search word(s) not found."
  End If
  MsgBox strSearchInfo, vbInformation + vbOKOnly, _
    "Search Information"
  
  Set modiTextSel = Nothing
  Set modiSearch = Nothing
  Set modiDoc = Nothing

End Sub

Methods | Initialize Method | Search Method

Parent Objects

Child Objects