读书人

关于office自带的OCR解决办法

发布时间: 2012-12-29 10:28:09 作者: rapoo

关于office自带的OCR

Dim strLayoutInfo As String, strLPN As String

'初始化并加载文档
Set miDoc = CreateObject("MODI.Document") '创建对象
miDoc.Create "D:\未命名.jpg" '加载图片文件

Screen.MousePointer = vbHourglass '设置光标忙
'识别
miDoc.Images(0).OCR miLANG_CHINESE_SIMPLIFIED, True, True '有用的就此一句,识别为中文简体 ============报错行

Set modiLayout = miDoc.Images(0).Layout '读出数据
strLayoutInfo = _
"Language: " & modiLayout.Language & vbCrLf & _
"Number of characters: " & modiLayout.NumChars & vbCrLf & _
"Number of fonts: " & modiLayout.NumFonts & vbCrLf & _
"Number of words: " & modiLayout.NumWords & vbCrLf & _
"Beginning of text: " & Left(modiLayout.Text, 50) & vbCrLf & _
"First word of text: " & modiLayout.Words(0).Text
MsgBox strLayoutInfo, vbInformation + vbOKOnly, "Layout Information"
Set modiLayout = Nothing
Set miDoc = Nothing
Screen.MousePointer = vbDefault

我添加工程->部件->添加这个控件:Microsoft Office Document Imaging 11.0 Type Library
了怎么一运行就报错:
object hasn't been initialized and can't be used yet


另外对于miDoc.Images(0).OCR miLANG_CHINESE_SIMPLIFIED, True, True 要是只识别数字怎么写。

也许只是差一点点,但是对于一个没有系统学过编程的人来说需要的就是您的点滴点拨。谢谢
[解决办法]
这个dll我怎么注册不了啊

读书人网 >VB

热点推荐