OnOCRProgress Event

Occurs periodically during an optical character recognition (OCR) operation. Returns the estimated percentage of the OCR operation that is complete, and allows the user to cancel the operation.

expression.OnOCRProgress(Progress, Cancel)

*expression   * Required. An expression that returns a Document object.

Progress     Integer. Returns the estimated percentage of an OCR operation that is complete (0 to 99).

Cancel     Boolean. Set *Cancel   * to true in the OnOCRProgress event procedure to cancel the OCR operation in progress.

Remarks

Use the Progress argument of the OnOCRProgressEvent with a ProgressBar control to keep the user informed of the status of an OCR operation. Provide a Cancel button that sets Cancel to true to allow the user to cancel the OCR operation.

Example

The following example uses a Visual Basic form containing two command buttons (cmdOCR and cmdCancel) and a progress bar control (pbrOCRProgress). While an OCR operation is in progress, the OnOCRProgress event procedure updates the progress bar control and cancels the operation if the user clicks the Cancel button.

Option Explicit
Private WithEvents mmiDoc As MODI.Document
Private mblnCancel As Boolean

Private Sub cmdCancel_Click()
  
  ' Set a flag indicating that the user wants to cancel.
  mblnCancel = True
  
End Sub

Private Sub cmdOCR_Click()

  ' Load an existing TIF file.
  Set mmiDoc = New MODI.Document
  mmiDoc.Create "C:\document1.tif"
  
  ' Perform OCR on the document
  Screen.MousePointer = vbHourglass
  mmiDoc.OCR
  Screen.MousePointer = vbDefault
  
  Set mmiDoc = Nothing
  
End Sub

Private Sub mmiDoc_OnOCRProgress(ByVal Progress As Long, _
                                 Cancel As Boolean)

  ' Cancel if user has clicked the Cancel button.
  If mblnCancel Then
      Cancel = True
  End If
  
  ' Indicate progress on the ProgressBar control
  pbrOCRProgress.Value = Progress
  
End Sub

Applies to | Document Object