Loading
Word.Tips.Net WordTips (Menu Interface)

Finding Changes by Editor

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.

Related Tips:

Do More in Less Time! Are you ready to harness the full power of Word 2013 to create professional documents? In this comprehensive guide you'll learn the skills and techniques for efficiently building the documents you need for your professional and your personal life. Check out Word 2013 In Depth today!

 

Leave your own comment:

*Name:
Email:
  Notify me about new comments ONLY FOR THIS TIP
Notify me about new comments ANYWHERE ON THIS SITE
Hide my email address
*Text:
*What is 5+3 (To prevent automated submissions and spam.)
 
 
           Commenting Terms

Comments for this tip:

Peter S.    08 Apr 2015, 08:24
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
Peter S.    08 Apr 2015, 02:51
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
 
 

Our Company

Sharon Parq Associates, Inc.

About Tips.Net

Contact Us

 

Advertise with Us

Our Privacy Policy

Our Sites

Tips.Net

Beauty and Style

Cars

Cleaning

Cooking

DriveTips (Google Drive)

ExcelTips (Excel 97–2003)

ExcelTips (Excel 2007–2016)

Gardening

Health

Home Improvement

Money and Finances

Organizing

Pests and Bugs

Pets and Animals

WindowsTips (Microsoft Windows)

WordTips (Word 97–2003)

WordTips (Word 2007–2016)

Our Products

Helpful E-books

Newsletter Archives

 

Excel Products

Word Products

Our Authors

Author Index

Write for Tips.Net

Copyright © 2016 Sharon Parq Associates, Inc.