Initialize Method
Initializes a search for the specified word or phrase in the recognized text of the specified page of a document.
expression.Initialize(piDoc, strPattern, PageNum, WordIndex, StartAfterIndex, Backward, MatchMinus, MatchFullHalfWidthForm, MatchHiraganaKatakana, IgnoreSpace)
*expression * Required. An expression that returns an MiDocSearch object.
piDoc Required Object. The Document object to search.
strPattern Required String. The word or phrase to search for.
PageNum Required Variant. The zero-based page number to search.
WordIndex Required Variant. The zero-based index of the word at which to begin the search.
StartAfterIndex Required Variant. A Boolean value that specifies whether to start on or after the specified *WordIndex *.
Backward Required Variant. A Boolean value that specifies whether to search forward or backward.
MatchMinus Optional Boolean. Default is True.
MatchFullHalfWidthForm Optional Boolean. Default is true.
MatchHiraganaKatakana Optional Boolean. Default is true.
IgnoreSpace Optional Boolean. Specifies whether to ignore spaces in the recognized text when searching for the specified word or phrase. Default is true.
Remarks
The Initialize method prepares 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 a number of additional search settings.
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 named txtSearch
, and then displays the results.
Sub TestSearch()
Dim miDoc As MODI.Document
Dim miSearch As MODI.MiDocSearch
Dim miTextSel As MODI.IMiSelectableItem
Dim strSearchInfo As String
Set miDoc = New MODI.Document
miDoc.Create "C:\document1.tif"
miDoc.Images(0).OCR
Set miSearch = New MODI.MiDocSearch
miSearch.Initialize miDoc, txtSearch.Text, 0, 0, False, False
miSearch.Search Nothing, miTextSel
If miTextSel.Words.Count > 0 Then
strSearchInfo = "The search found " & _
miTextSel.Words.Count & _
" instances of the search word(s)."
Else
strSearchInfo = "Search word(s) not found."
End If
MsgBox strSearchInfo, vbInformation + vbOKOnly, _
"Search Information"
Set miTextSel = Nothing
Set miSearch = Nothing
Set miDoc = Nothing
End Sub
Applies to | MiDocSearch Object