Page 1 of 2 12 LastLast
Results 1 to 10 of 12

read the data from tiff file using MODI and OCR in VBA

This is a discussion on read the data from tiff file using MODI and OCR in VBA within the Excel Questions forums, part of the Question Forums category; Hi, Can any body correct me to read the data from tiff image by using MODI and OCR . Plz ...

  1. #1
    Board Regular
    Join Date
    Nov 2008
    Posts
    51

    Default read the data from tiff file using MODI and OCR in VBA

    Hi,
    Can any body correct me to read the data from tiff image by using MODI and OCR .
    Plz check the code.
    Dim doc1 As MODI.Document
    Dim inputFile As String
    Dim strRecText As String
    Dim imageCounter As Integer

    inputFile = Application.GetOpenFilename
    '(Title:="Please choose a file to import", _
    'FileFilter:="Image Files *.tif (*.tif)")
    strRecText = ""
    Set doc1 = New MODI.Document
    doc1.Create (inputFile)
    doc1.OCR ' this will ocr all pages of a multi-page tiff file
    doc1.Save ' this will save the deskewed reoriented images, and the OCR text, back to the inputFile
    For imageCounter = 0 To (doc1.Images.Count - 1) ' work your way through each page of results
    strRecText = strRecText & doc1.Images(imageCounter).Layout.Text ' this puts the ocr results into a string
    Next

    File.AppendAllText("C:\test\testmodi.txt", strRecText) ' write the OCR file out to disk
    doc1.Close
    doc1 = Nothing



    that program is showing error in the colored line.

    Regards,
    Divya Agarwal



  2. #2
    Board Regular Blade Hunter's Avatar
    Join Date
    Mar 2008
    Location
    Sydney, Australia
    Posts
    2,825

    Default Re: read the data from tiff file using MODI and OCR in VBA

    Why not use a more traditional method to write to a text file?

    Replace your failing line with the following 4 lines.

    Code:
    fnum = FreeFile()
    Open "C:\test\testmodi.txt" For Output As fnum
    Print #fnum, strRecText
    Close #fnum
    .select, overused and inefficient.

  3. #3
    Board Regular Blade Hunter's Avatar
    Join Date
    Mar 2008
    Location
    Sydney, Australia
    Posts
    2,825

    Default Re: read the data from tiff file using MODI and OCR in VBA

    Oh also, Doc1=nothing gave me issues so I commented that out to get it working too.
    .select, overused and inefficient.

  4. #4
    Board Regular
    Join Date
    Nov 2008
    Posts
    51

    Default Re: read the data from tiff file using MODI and OCR in VBA


    object has not been initialised and can not be used yet while i try to make OCR the image

  5. #5
    Board Regular
    Join Date
    Nov 2008
    Posts
    51

    Default Re: read the data from tiff file using MODI and OCR in VBA

    getting the previous error

  6. #6
    Board Regular Blade Hunter's Avatar
    Join Date
    Mar 2008
    Location
    Sydney, Australia
    Posts
    2,825

    Default Re: read the data from tiff file using MODI and OCR in VBA

    This is the complete code I used.

    Code:
    Sub OCRReader()
    Dim doc1 As MODI.Document
    Dim inputFile As String
    Dim strRecText As String
    Dim imageCounter As Integer
    inputFile = Application.GetOpenFilename
    strRecText = ""
    Set doc1 = New MODI.Document
    doc1.Create (inputFile)
    doc1.OCR ' this will ocr all pages of a multi-page tiff file
    For imageCounter = 0 To (doc1.Images.Count - 1) ' work your way through each page of results
        strRecText = strRecText & doc1.Images(imageCounter).Layout.Text ' this puts the ocr results into a string
    Next
    fnum = FreeFile()
    Open "C:\Test\testmodi.txt" For Output As fnum
        Print #fnum, strRecText
    Close #fnum
    doc1.Close
    End Sub
    .select, overused and inefficient.

  7. #7
    Board Regular Blade Hunter's Avatar
    Join Date
    Mar 2008
    Location
    Sydney, Australia
    Posts
    2,825

    Default Re: read the data from tiff file using MODI and OCR in VBA

    Oh almost forgot, make sure you add "Microsoft Office Document Imaging 11.0 Type Library" in as a reference
    .select, overused and inefficient.

  8. #8
    Board Regular
    Join Date
    Nov 2008
    Posts
    51

    Default Re: read the data from tiff file using MODI and OCR in VBA

    ihave Microsoft Office Document Imaging 12.0 Lobrary

    and while i do select this and run the progm it display error

    "name conflicts with existing module,project or library"

  9. #9
    Board Regular
    Join Date
    Nov 2008
    Posts
    51

    Default Re: read the data from tiff file using MODI and OCR in VBA

    Thank u so much
    i got my error i delect previous one 1.0 type library and select 12.0 type.
    It is working.

    Cooooooooool

    Thanks a lot

  10. #10
    Board Regular Blade Hunter's Avatar
    Join Date
    Mar 2008
    Location
    Sydney, Australia
    Posts
    2,825

    Default Re: read the data from tiff file using MODI and OCR in VBA

    Happy to help
    .select, overused and inefficient.

Page 1 of 2 12 LastLast

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com