A VBA macro for Microsoft Word to count the numbers of changes made by specific authors.
AuthorCheck scans all comments and revisions in the active Word document, groups them by author, and outputs a summary showing:
- Number of revisions per author;
- Number of comments per author.
It uses a Scripting.Dictionary to store authors and counters, avoiding the complexity and fragility of manually managed arrays.
I previously attempted to make a Word VBA macro for counting changes in a document by author. My prior attempts failed for reasons related to Word's backend, and further research has given me a working solution, which I provide separately here for sake of clarity.
Dim dictAuthors As Object
Set dictAuthors = CreateObject("Scripting.Dictionary")Each dictionary entry uses the author name as the key and a 2‑element array as the value:
(0) = number of revisions
(1) = number of comments
For Each c In ActiveDocument.Comments
author = c.Author
If Not dictAuthors.Exists(author) Then
dictAuthors.Add author, Array(0, 0)
End If
Next cThe same logic is applied to revisions. This ensures each author is added exactly once.
arrC = dictAuthors(author)
arrC(1) = arrC(1) + 1
dictAuthors(author) = arrCThe macro updates the counters cleanly without resizing arrays or searching for matching authors.
For Each key In dictAuthors.Keys
output = output & "Editor: " & key & vbCrLf & _
"Changes: " & dictAuthors(key)(0) & vbCrLf & _
"Comments: " & dictAuthors(key)(1) & vbCrLf & vbCrLf
Next keyOlder macros used patterns like:
ReDim Preserve AuthorList(ArrayPos)This is slow, fragile, and easy to break. AuthorCheck avoids arrays entirely by using a dictionary.
AuthorArrayCheck contained logic like:
CountArray = ArrayPosThis causes unpredictable behavior. AuthorCheck uses For Each, which avoids index manipulation entirely.
Older macros manually searched arrays to check if an author already existed.
AuthorCheck replaces all of that with:
If Not dictAuthors.Exists(author) Then ...This is faster and simpler.
ChangeCheck and SelectionCheck required the user to type an author name exactly as Word stores it.
AuthorCheck automatically discovers all authors, eliminating user error.
SelectionCheck depended on Selection.Range.Revisions, which is unreliable.
AuthorCheck always uses the full document, where Word’s revision model is stable.
Older macros repeated the same loops multiple times.
AuthorCheck uses a clean two‑pass structure:
- Collect authors;
- Count items.