hello friends,
i am trying to use microsoft office document imaging library in my c# application to add OCR functionality to my application.However when i tried to run the following piece of code the compiler threw an error

"
Retrieving the COM class factory for component with CLSID {56F963EC-6EFC-4A6B-9A1E-5BFE545C89D0} failed due to the following error: 80040154.
"

my code goes as follows:

..    
        md = new MODI.Document();
            md.Create("OCR.tif");   //OCR.tif is name of image 
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
            md.Close(false);

//ERROR WAS SHOWN IN FOLLOWING LINE

            MODI.Image image = new MODI.Image();
          

MODI.Layout layout = image.Layout;
            MODI.Word word = (MODI.Word)layout.Words[5];
....

i have added reference to MODI and MSOFFICE LIBRARY but doesn't work.

Hallo,
my annotations are in your code...

my code goes as follows:

..    
        md = new MODI.Document();
            md.Create("OCR.tif");   //OCR.tif is name of image 
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
            md.Close(false);
<- In this line you closed the document, so you can no longer access it.

//ERROR WAS SHOWN IN FOLLOWING LINE

            MODI.Image image = new MODI.Image();
<- you want your image as part of you document, so that you can read the text later

MODI.Layout layout = image.Layout;
            MODI.Word word = (MODI.Word)layout.Words[5];
....
..    
            md = new MODI.Document();
            md.Create("OCR.tif");   //OCR.tif is name of image 
            md.OCR(MODI.MiLANGUAGES.miLANG_ENGLISH, true, true);
//if you have a multipage .tif you have to loop over the number of //pages
            MODI.Image image = md. Images[0];
            MODI.Layout layout = image.Layout;
            MODI.Word word = (MODI.Word)layout.Words[5];
....
           md.Close(false);

Hope that helps

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.