Using VB to invoke Office OCR components for graphic recognition
Original: http://sheng.iteye.com/blog/1330063
Office OCR Graphics recognizes Microsoft office Document Imaging
Option Explicit
' OCR recognition of images using the MS Office 2003/2007 OCR control
In VB, only less than 10 lines of code will be able to implement their own OCR word recognition software.
' 1. Add control, need to install office2003, no installation office2003 can copy related files from others, register Regsvr32.exe mdivwctl.dll,
' control is generally in this directory: C:\Program files\common Files\Microsoft shared\modi.0, only need the relevant several files on it, this folder all files about 21M.
' 2. Add this control with parts, engineering--Microsoft Office Document Imaging 11.0 Type Library
' 3. It is important to note that on Windows2003 server, if you use Office-brought identification software, you will get an error:
' "Error in performing OCR unsuccessful (text not found) on one or more pages, but it is normal for the test program to be written in VB.
' Main functions of OCR
Private Function ocrimagefile (ByVal strimagefilename as String) as Boolean
Dim Midoc as Object
' Initialize and load document
Set Midoc = CreateObject ("MODI. Document ") ' Create object
Midoc.create (strimagefilename) ' Loading picture file
Screen.MousePointer = Vbhourglass ' Set hourglass cursor
' Recognition
Err.Clear
Midoc.images (0). OCR 2052, True, True
Text1.Text = midoc.images (0). Layout.text
Ocrimagefile = True
Screen.MousePointer = Vbarrow ' Restore arrow cursor
End Function
Private Sub Cmdocr_click ()
Dim Bolp as Boolean
Dim strFileName as String
strFileName = "C:\test.tif"
Bolp = Ocrimagefile (strFileName)
End Sub
Office OCR Graphics Identify Microsoft office Document Imaging (GO)