Reputation: 57
I want to compare 2 word documents in c# sideby side and get Different text or sentences in the word documents(.doc or .docx) as a report and the report can be highlighting the differences in side by side and am using following code
Application wordApp = new Application();
wordApp.Visible = true;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"D:\MyWorks\test1.doc";
object missing = Type.Missing;
Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref wordTrue, ref missing,
ref missing, ref missing, ref missing);
object fileToOpen1 = @"D:\MyWorks\test2.doc";
Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
Document doc = wordApp.CompareDocuments(doc1, doc2, WdCompareDestination.wdCompareDestinationNew, WdGranularity.wdGranularityWordLevel,
true, true, true, true, true, true, true, true, true, true, "", true);
the above code giving follwing error
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
please help me in this aspect and i want run this in system which does't contain ms-office installed version plese provide some gudilines
thanks
Sree
Upvotes: 0
Views: 1342
Reputation: 10899
You cannot use Microsoft Office Interop without Office installed - it is flatout impossible. Moreover: You are in an server environment, running Office is not recommended by Microsoft because there are lots of threading issues and sometimes a messagebox from Office will hang your thread.
You have two choices: - use the Office Open XML Sdk to compare the documents, but this is a lot of work because it is very different from Interop. There is the free book "Open XML Explained" which could help to get you started. - Use a library which capsules the Office Open XMl SDK - I never used the libraries for word, so I cannot give you an advice.
Upvotes: 2