How to determine if two-word documents match using the word interop

Is there a good way to see if two documents are the same using the word interop?

I tried using something like:

Word.Document tempDoc = app.CompareDocuments(document1, document2); 

My problem is that tempDoc is not null if they are the same, so I'm not sure how to use this result to determine if the documents are the same.

Thanks in advance!

+2
source share
1 answer

A returned document is a document with track changes enabled. So all you have to do is see if there are any changes. So:

 Document tempDoc = app.CompareDocuments(doc1, doc2); bool anyChanges = tempDoc.Revisions.Count > 0; 

See:

http://msdn.microsoft.com/en-us/library/microsoft.office.interop.word._application.comparedocuments.aspx

+9
source

Source: https://habr.com/ru/post/902217/


All Articles