In VBA macro, accessing any comment via "For Each... "causes Run-time error 5825
VBA has a bug in 2024 versions of Word. Anytime I try to access a comment in a macro using "For Each...", I get a Run-time error 5825 "Object has been deleted". This bug occurs on recent versions of Word on Mac, e.g. 16.85, but not on older versions, e.g. 16.77). "For Each" continues to work for other collections (e.g. Fields)
E.g. a simple test macro, run on any doc containing one or more comments, fails:
Sub testcomm()
For Each comm In ActiveDocument.Comments
x = comm.Scope
Next
End Sub
I found a workaround: replace the above macro with
Sub testcomm2()
For cntr = 1 To ActiveDocument.Comments.Count
x = ActiveDocument.Comments(cntr).Scope
Next
End Sub