View Single Post
 
Old 07-17-2021, 03:43 AM
Downunder Dave Downunder Dave is offline Windows 7 64bit Office 2010
Novice
 
Join Date: Jul 2021
Location: New Zealand
Posts: 3
Downunder Dave is on a distinguished road
Default Use VBA to compare Text Box contents between documents.

Hi,


I am using Word 2010 for this exercise.


I currently have a piece of VBA that compares two documents (using either the CompareDocuments or Compare methods) and this produces a quick summary of the number of differences, their type (Insert/Delete) and the number of characters involved.



Each of the CompareDocuments or Compare methods produce an interim Results document, just as you get when doing this process manually via the Word toolbar/menu. The Results document I get with VBA clearly shows the text of each difference and whether that difference is within the:
Main Document
Header/Footer
Text Boxes
Header/Footer Text Boxes
Footnotes
Endnotes


Once I create an object of the Results document, I can easily iterate through the differences that are in the Main Document, like this:
For Each dsRevision In oResDoc.Revisions
If dsRevision.Type = wdRevisionInsert Then
sngCharacters = sngCharacters + dsRevision.Range.Characters.Count
End If
Next


My problem is that the VBA Revisions collection only seems to include differences that are in the Main Document and nowhere else.



These differences in other locations are clearly being found, I just cannot inspect them with VBA.


I may be missing something fundamental here. Does anyone know how I can use VBA to iterate across the Revisions that appear in the Footnote/Header and Text Box sections of the Results document ?



Many thanks,


Downunder Dave
Reply With Quote