How to determine whether two word documents are the same using word interop

我与影子孤独终老i 提交于 2019-12-11 03:47:07

问题


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

I have tried using something like:

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

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

Thanks in advance!


回答1:


The document it returns is a document with track changes turned on. 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



来源:https://stackoverflow.com/questions/12321490/how-to-determine-whether-two-word-documents-are-the-same-using-word-interop

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!