a Macro for Word that counts Track Changes yields errors :(

Not open for further replies.


New member
Dec 19, 2019
Programming Experience
Hi Everyone,

I need help in VB since I am not a coder.

Translation professionals around the world pass on to each other a Word Macro called GetTCStats in order to count insertions and deletions made in a Word document with Track Changes.

In some documents, it does not work at all, and it yields "Requested object is not available" (Run-time error '5852') and when I open debugging it highlights the line "Select Case oRevision.Type"

In other documents I tested, it worked fine, and there's no error, but when I "step into" and hover the "Select Case" line, I see it has an "oRevision.Type = <Object variable or With block variable not set>" comment.

Is the object not set correctly? Can anyone help solve this issue?

Very grateful for any help,


note: if I did not post according to posting guidelines, my apologies, I am new to this.


Sub GetTCStats()
Dim lInsertsWords As Long
Dim lInsertsChar As Long
Dim lDeletesWords As Long
Dim lDeletesChar As Long
Dim sTemp As String
Dim oRevision As Revision
lInsertsWords = 0
lInsertsChar = 0
lDeletesWords = 0
lDeletesChar = 0
For Each oRevision In ActiveDocument.Revisions
Select Case oRevision.Type
Case wdRevisionInsert
lInsertsChar = lInsertsChar + Len(oRevision.Range.Text)
lInsertsWords = lInsertsWords + oRevision.Range.Words.Count
Case wdRevisionDelete
lDeletesChar = lDeletesChar + Len(oRevision.Range.Text)
lDeletesWords = lDeletesWords + oRevision.Range.Words.Count
End Select
Next oRevision
sTemp = "Insertions" & vbCrLf
sTemp = sTemp & " Words: " & lInsertsWords & vbCrLf
sTemp = sTemp & " Characters: " & lInsertsChar & vbCrLf
sTemp = sTemp & "Deletions" & vbCrLf
sTemp = sTemp & " Words: " & lDeletesWords & vbCrLf
sTemp = sTemp & " Characters: " & lDeletesChar & vbCrLf
MsgBox sTemp
End Sub


  • GetTCStats.txt
    1.1 KB · Views: 9
  • Image 1039.jpg
    Image 1039.jpg
    309.8 KB · Views: 6
  • Image 1038.jpg
    Image 1038.jpg
    68.7 KB · Views: 6


VB.NET Forum Moderator
Staff member
Aug 17, 2004
Sydney, Australia
Programming Experience
Macros for Word and other Office products are written in VBA, which is a different language to VB.NET, even though the syntaxes are closely related. I'm afraid that this is npt a valid question for this site.
Not open for further replies.
Top Bottom