1

我试图从图片文档中获取所有信息。其中包括某些部分的手写。在扫描此即时消息时,我的屏幕冻结得像地狱一样,然后给出一个错误,说 VB6 停止工作......我真的不知道是什么原因造成的,所以如果出现错误或 OCR 故障,我只想克服它。可惜还没有成功。这是我到目前为止所做的:

Dim Mdoc As MODI.Document
Dim Mlay As MODI.Layout
Dim fso As Scripting.FileSystemObject
Dim logfile As Object

Public Function ScanMan(ByVal Name As String, ByVal Path As String) As String
    Set Mdoc = New MODI.Document
    'Set Mdoc = CreateObject("MODI.Document")
    Set fso = New Scripting.FileSystemObject

    DoEvents
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''' Create OCRLog File '''''''''''''''''''
    OCRPath = App.Path & "\OCR Results Log\"
    OCRName = Str(DateTime.Date) & " OCRresults"
    If fso.FolderExists(OCRPath) = False Then
        fso.CreateFolder (OCRPath)
    End If
    If fso.FileExists(OCRPath & OCRName & ".txt") = False Then
        fso.CreateTextFile OCRPath & OCRName & ".txt"
    End If
    Set logfile = fso.OpenTextFile(OCRPath & OCRName & ".txt", ForAppending)
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

    On Error GoTo OCRErr
    DoEvents
    Mdoc.Create Path & Name
    Mimg = Mdoc.Images(0).OCR(miLANG_ENGLISH, True, True)
    Set Mlay = Mdoc.Images(0).Layout
    logfile.WriteLine Mlay.Text

    ScanMan = Mlay.Text

    Mdoc.Close False

    Set Mlay = Nothing
    Set Mdoc = Nothing

OCRErr:
    logfile.WriteLine "OCR given (" & Err.Number & ") numbered (" & Err.Description & ") error."
    logfile.Close
End Function

那么我该如何处理这个冻结问题呢?

4

1 回答 1

1

尝试这个:

Mdoc.Images(0).OCR
logfile.Write Mdoc.Images(0).Layout.Text

希望这可以帮助。

于 2012-06-01T10:31:54.193 回答