Finding Changes by Editor

by Allen Wyatt
(last updated October 1, 2014)

2

Subscriber Doris Bell asked if there was a way, in Word 2000, to locate all the changes made by a particular editor in a document that has Track Changes turned on. The quick answer, of course, would be to upgrade to Word 2002, since this capability is available right from the Reviewing toolbar.

Word 97 and Word 2000, however, are a different story--there you only have the capability to view or not view all tracked changes. If desired, you can address the deficiency by creating macros that allow you to search for changes by a specific editor. Start by creating a user form in the VBA Editor, by following these general steps:

  1. Display the VBA Editor by pressing Alt+F11.
  2. Choose UserForm from the Insert menu. A blank user form is displayed in the editor.
  3. Using the Toolbox, place a Label control in the form, near the left side of the form.
  4. In the Properties for the newly placed Label control, change the Caption property to "Author" (without the quotes).
  5. Using the Toolbox, place a ComboBox control just to the right of the label you placed in step 3.
  6. In the Properties for the ComboBox control, change the Name property to "cboAuthor" (without the quotes).
  7. Using the Toolbox, place a CommandButton control on the form. This can be along the bottom edge of the form, or on the right edge; it is up to you.
  8. In the Properties for the CommandButton control, change the Name property to "cmdFindNext" (without the quotes).
  9. In the Properties for the CommandButton control, change the Caption property to "Find" (without the quotes).
  10. Using the Toolbox, place another CommandButton control on the form. This should be either just to the right of the other CommandButton control, or just below it.
  11. In the Properties for the CommandButton control, change the Name property to "cmdExit" (without the quotes).
  12. In the Properties for the CommandButton control, change the Caption property to "Exit" (without the quotes).
  13. Resize your overall form for the desired appearance.

Your form is now complete, and all you need to do is add the programming code that will take advantage of these controls. Make sure you select the entire form, and then press F7 to display the Code window. If there is any code already there (VBA may provide some default code for you), feel free to delete it. Then, place the following code in the Code window:

Private Sub UserForm1_Initialize()
    Dim oRevision As Revision
    Dim bExists As Boolean

    bExists = False

    ' Go to beginning of document
    Selection.HomeKey Unit:=wdStory

    ' Loop through revisions and add authors
    For Each oRevision In ActiveDocument.Revisions
        If Me.cboAuthor.ListCount > 0 Then
            For i = 1 To Me.cboAuthor.ListCount
                If Me.cboAuthor.List(i - 1) = oRevision.Author Then
                    bExists = True
                End If
            Next i

            ' If it doesn't already exist, add the author to list
            If Not bExists Then
                Me.cboAuthor.AddItem oRevision.Author
            End If

            bExists = False
        Else
            ' Add first Author to the list
            Me.cboAuthor.AddItem oRevision.Author
        End If
    Next oRevision
End Sub

Private Sub cmdExit_Click()
    Unload Me
End Sub

Private Sub cmdFindNext_Click()

    Dim iStart As Integer
    Dim iEnd As Integer
    Dim myRange As Range
    Dim iRevisions As Integer
    Dim iResponse As Integer
    Dim bAuthorFound As Boolean

    ' Collapse the Selection so that we don't include selected text
    Selection.Collapse wdCollapseEnd
    Selection.MoveRight wdCharacter, 2

    ' Get the Range start and end positions
    iStart = Selection.Range.Start
    iEnd = ActiveDocument.Content.End
    Set myRange = ActiveDocument.Range(Start:=iStart, End:=iEnd)

    ' Count total number of revisions within range
    iRevisions = myRange.Revisions.Count

    If iRevisions > 0 Then
        ' Loop through all revisions in the range 
        ' selecting first one found
        For i = 1 To iRevisions
            If myRange.Revisions(i).Author = Me.cboAuthor.Text Then
                myRange.Revisions(i).Range.Select
                bAuthorFound = True
                Exit For
            Else
                bAuthorFound = False
            End If
        Next i
    End If

    If Not bAuthorFound Then
        ' Ask if they would like to start from the beginning
        iResponse = MsgBox("Search from beginning?", vbYesNo, "Find Author")
        If iResponse = vbYes Then
            ' Go to top of document
            Selection.HomeKey Unit:=wdStory
            cmdFindNext_Click
        Else
            ' Exit
            Unload Me
        End If
    End If
End Sub

When you later run your new user form, you are presented with a way to select editors and find the next edit made by that editor. This allows you to find one edit at a time, not to view all the edits by a particular editor (as you can in Word 2002).

There is a different approach you can take. You could use a macro to "pull" all the edits done in a document, and arrange them by editor in a new document. The following macro shows how you can do this sort of thing. The resulting table even indicates the type of edit done in the original document.

Option Explicit

Private Sub ShowAuthorAndRevisions()
    Dim sRevision As String
    Dim oRev As Revision
    Dim oDoc As Document
    Dim oRng As Range

    For Each oRev In ActiveDocument.Revisions
        With oRev
            sRevision = sRevision & .Author & vbTab _
              & .Type & vbTab & .Range.Text & vbCrLf
        End With
    Next oRev

    ' Open a new document
    Set oDoc = Documents.Add
    With oDoc
        .Range.InsertAfter sRevision
        ' Convert the revisions to a table
        .Range.ConvertToTable Separator:=wdSeparateByTabs
        With .Tables(1)
            ' Sort the table by the author (i.e., the first column)
            .Range.Sort
            ' Add a new row to the beginning of the table
            .Range.Rows.Add BeforeRow:=.Range.Rows(1)
            With .Rows(1)
                ' insert column descriptions
                .Cells(1).Range.Text = "Author"
                .Cells(2).Range.Text = "Revision Type"
                .Cells(3).Range.Text = "Revision"
            End With
        End With
        ' insert a paragraph mark above the table
        Selection.SplitTable
        ' Insert a legend to make reading the revision type easier
        .Range.InsertBefore "Revision Type Legend:" & vbCrLf & _
            "No Revision = 0 " & vbCrLf & _
            "Revision Insert = 1 " & vbCrLf & _
            "Revision Delete = 2 " & vbCrLf & _
            "Revision Property = 3 " & vbCrLf & _
            "Revision Paragraph Number = 4 " & vbCrLf & _
            "Revision Display Field = 5 " & vbCrLf & _
            "Revision Reconcile = 6 " & vbCrLf & _
            "Revision Conflict = 7 " & vbCrLf & _
            "Revision Style = 8 " & vbCrLf & _
            "Revision Replace = 9 " & vbCrLf
    End With
End Sub

For each revision in a document, this macro will find the revision's author, type, and text (if any). The macro will then place all the revisions in a table, sort the table by the name of the author, and insert a small legend that describes each revision type.

WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (1303) applies to Microsoft Word 97, 2000, and 2002.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...

MORE FROM ALLEN

Making Hyperlinks from Coded Text

Sometimes you may receive documents from others that you need to process in some way. Word's Find and Replace capabilities ...

Discover More

Word Styles and Templates

Styles are at the heart of Word's formatting power. Understanding how to use styles can greatly increase your ability to ...

Discover More

Determining the Size of a File

When processing a document using a macro, you may need to know the precise size of a particular file. The way you figure this ...

Discover More

Learning Made Easy! Quickly teach yourself how to format, publish, and share your content using Word 2013. With Step by Step, you set the pace, building and practicing the skills you need, just when you need them! Check out Microsoft Word 2013 Step by Step today!

More WordTips (menu)

Comparing Document Versions

Do you need to compare two versions of a document to each other? Word provides a tool that can make this easy, as described ...

Discover More

Starting a Discussion

Tips for getting your Discussion started.

Discover More

Stopping Smart Tags from Being Saved

Don't want Smart Tag information saved with your document? It's easy to make sure that Word doesn't save it, as described in ...

Discover More
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.

Comments

If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 6 - 0?

2015-04-08 08:24:09

Peter S.

Here the full working code with work arrounds:

Dim ThisDocument As Object
Private Sub UserForm_Activate()
Dim oRevision As Revision
Dim bExists As Boolean

Set ThisDocument = ActiveDocument
bExists = False

' Go to beginning of document
Selection.HomeKey Unit:=wdStory

' Loop through revisions and add authors
For Each oRevision In ThisDocument.Revisions
If Me.cboAuthor.ListCount > 0 Then
For i = 1 To Me.cboAuthor.ListCount
On Error Resume Next
If Me.cboAuthor.List(i - 1) = oRevision.Author Then
bExists = True
End If
Next i

' If it doesn't already exist, add the author to list
If Not bExists Then
Me.cboAuthor.AddItem oRevision.Author
End If

bExists = False
Else
' Add first Author to the list
Me.cboAuthor.AddItem oRevision.Author
End If
Next oRevision
Me.cboAuthor.ListIndex = 0
End Sub

Private Sub cmdExit_Click()
Unload Me
End Sub

Private Sub cmdFindNext_Click()

Dim iStart As Long
Dim iEnd As Long
Dim myRange As Range
Dim iRevisions As Long
Dim iResponse As Long
Dim bAuthorFound As Boolean
Dim txtAuthor As String
ThisDocument.Activate
' Collapse the Selection so that we don't include selected text
Selection.Collapse wdCollapseEnd
Selection.MoveRight wdCharacter, 2

' Get the Range start and end positions
iStart = Selection.Range.Start
iEnd = ThisDocument.Content.End
Set myRange = ThisDocument.Range(Start:=iStart, End:=iEnd)

' Count total number of revisions within range
iRevisions = myRange.Revisions.Count



If iRevisions > 0 Then
' Loop through all revisions in the range
' selecting first one found
For i = 1 To iRevisions
txtAuthor = "failed"
On Error Resume Next
txtAuthor = myRange.Revisions(i).Author
On Error GoTo 0
If txtAuthor <> "failed" Then
If txtAuthor = Me.cboAuthor.Text Then
myRange.Revisions(i).Range.Select
bAuthorFound = True
Exit For
Else
'Failure, resize myRange
iStart = iStart + 1
Set myRange = ThisDocument.Range(Start:=iStart, End:=iEnd)
End If
End If
Next i
End If

If Not bAuthorFound Then
' Ask if they would like to start from the beginning
iResponse = MsgBox("Search from beginning?", vbYesNo, "Find Author")
If iResponse = vbYes Then
' Go to top of document
Selection.HomeKey Unit:=wdStory
cmdFindNext_Click
Else
' Exit
Unload Me
End If
End If
End Sub


2015-04-08 02:51:29

Peter S.

Works fine for me when I put
"On Error Resume Next"
before line
"If Me.cboAuthor.List(i - 1) = oRevision.Author Then"
Else I get an error message:
oRevision.Author=<Method 'Author' of object 'Revision'failed>
It failes only at one revision. All before and after are ok.

Also I had to change
Dim iEnd As Integer
to
Dim iEnd As Long

I have a long document, 230 pages. Word2000


This Site

Got a version of Word that uses the menu interface (Word 97, Word 2000, Word 2002, or Word 2003)? This site is for you! If you use a later version of Word, visit our WordTips site focusing on the ribbon interface.

Newest Tips
Subscribe

FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.