'How to check if Word document content has been changed
I'm looking forward for method to check if document has been changed.
- Property
Activedocument.Savedis not enough, because if you change sth and undo this, document hasn't been changed but.Savedwill change. - Checksum of document text will be not enough, because not including change in formatting (bold, italic etc.).
- Date/time and file size will be not enough (beacuse save command can change its even without change in document).
- build-in in MS Word compare - I cant use this, beacuse first at all im working on subdocuments (one main document contain several subdocuments and I want to know which subdocument has been changed) and I don't want to create copy of subcdocuments, or create new document object to compare.
I invented that I will make checksum from .WordOpenXML.
On open main document I calculate checksum
For each sd in Activedocument.SubDocuments
'calculate and remember checksum of subDocument
...
Next sd
On close main document
For each sd in Activedocument.SubDocuments
'calculate and compare with previous checksum of subDocument
...
Next sd
But every check of .WordOpenXML return different value. It looks like WordOpenXML value is generated on each call.
Is it way to avoid this?
Debug.Print Selection.WordOpenXML=Selection.WordOpenXML
Resume False :-)
Or maybe you have other method to check if document has been changed?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
