Question

I Planned to use OCR in my project and searched more OCR methods and i didnt find anything correctly. And at last i heard about MODI and i tried that . But It throwing Following error:

Retrieving the COM class factory for component with CLSID {40942A6C-1520-4132-BDF8-BDC1F71F547B} failed due to the following error: 80040154

I'm Using Microsoft Office 2013 and visual studio 2012.

The code me using is follows:

 private void button1_Click(object sender, EventArgs e)
    {
        CheckFileType(@"E:\\");
    }

    public void CheckFileType(string directoryPath) 
    { 
        IEnumerator files = Directory.GetFiles(directoryPath).GetEnumerator(); 
        while (files.MoveNext()) 
        { 
        //get file extension 
        string fileExtension = Path.GetExtension(Convert.ToString(files.Current));

        //get file name without extenstion 
        string fileName=Convert.ToString(files.Current).Replace(fileExtension,string.Empty);

        //Check for JPG File Format 
        if (fileExtension == ".jpg" || fileExtension == ".JPG") // or // ImageFormat.Jpeg.ToString()
        { 
        try 
        { 
        //OCR Operations ... 
        MODI.Document md = new MODI.Document(); 
        md.Create(Convert.ToString(files.Current)); 
        md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true); 
        MODI.Image image = (MODI.Image)md.Images[0];
        //create text file with the same Image file name 
        FileStream createFile = new FileStream(fileName + ".txt",FileMode.CreateNew);

        //save the image text in the text file 
        StreamWriter writeFile = new StreamWriter(createFile); 
        writeFile.Write(image.Layout.Text); 
        writeFile.Close(); 
        } 
        catch (Exception) 
        { 
        MessageBox.Show("This Image hasn't a text or has a problem", 
        "OCR Notifications", 
        MessageBoxButtons.OK, MessageBoxIcon.Information); 
        } 
        } 
        } 
    } 

Can anyone help me in this ? Is that problem based on Microsoft Office version or Do i Need to make any changes ? Is that any better OCR dll ? thanks ..

No correct solution

OTHER TIPS

I believe that to use MODI the image must be in .tiff format or Microsoft's proprietary .modi format. According to your code, it looks like you are trying to convert a jpg.

Check this link for an example in VB.NET for converting TIFF to JPEG and vice versa.

http://code.msdn.microsoft.com/windowsdesktop/VBTiffImageConverter-f8fdfd7f

I have solved this problem changing on below setting Go to Project Property -> Built tab -> change platform target to x86

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top