ISSUE: How to fix a Word VBA FOR EACH subroutine that seeks to insert a comment at each tracked change and, yet, will freeze VBA/Word at certain pages of a document and not other pages.
The below code works on some documents throughout the entire document. Other documents, unfortunately, will freeze at certain locations in the document.
I've F8 stepped through, for example, to find one document would freeze at pages 6 and 7 of a 22 page document. Strangely, however, I could run the code to insert comments at each tracked pages on all other pages.
Dim rev As Revision, txt As String
Dim pgno1 As String
Dim pgno2 As String
Application.ScreenUpdating = False
ActiveDocument.TrackRevisions = False
'check Revisions
For Each rev In ActiveDocument.Revisions
Select Case rev.Type
Case wdRevisionDelete
txt = Left(rev.Range.Text, 3) 'the deleted text
rev.Range.Comments.Add Range:=rev.Range, Text:="Pg [#" & pgno1 & "] BLAH " & txt & " [ ... ]“
Case wdRevisionInsert
txt = Left(rev.Range.Text, 3) 'the inserted text
rev.Range.Comments.Add Range:=rev.Range, Text:= "Pg [#" & pgno1 & "] BLAH " & txt & " […]”
End Select
Next rev
ActiveDocument.TrackRevisions = True
GOAL: Insert comment with specific text at each tracked change, throughout entire docxz
ERRORS: No messages. VBA and Word freeze, requiring restart.