Counting Inserted and Deleted Words in Track Changes

While pondering which topic should I write about first, along came a project, and with it an interesting challenge that I thought could turn into an article.

In some highly regulated industries such as Legal and Pharmaceuticals/Healthcare it is not uncommon to get requests for updating an existing translation where the edits in the new version of the source document are indicated by the Track Changes feature.
This type of project presents a unique challenge for quoting, scheduling and processing.

The Challenge: How to get the Track Changes statistics?

The main challenge in this type of project is to get a reliable revision statistics to base the quote and scheduling consideration on.
The first statistic that comes to mind is the word count of the insertions and deletions, however, the word count alone is usually not enough because this is not a straightforward translation project. The number of insertions and deletions can significantly affect the complexity level of the project because each edit needs to be identified in the source, its correspondent location needs to be found in the translated document (and with some documents that lack any orienting elements such as numbers, bullet lists or unique formatting this could be quite difficult), and only then the real work of translation begins. In other words, translating an insertion of 1,000 words in one continuous text segment is a lot easier than revising 1,000 individual insertions of one word, although on first look the word count of these two examples is the same.
Hence, a more detailed statistics is needed.

The Solution: The Reviewing Pane and a Macro

There are different methods to approach this challenge. Some save a copy of the file, then accept all the changes and compare the two versions to get a rough word count. If a TM of the previous translation is available it can be leveraged in a Translation Environment Tool such as OmegaT, SDL Studio, MemoQ, etc., including the very efficient way of working with DOCX files that contain Track Changes that was introduced in SDL Studio 2011 SP2, as explained in more details in an article by Paul Filkin, and I’m sure that there are more methods and tricks being used that I know nothing about.
Personally I find the first method described above too risky and inaccurate, and there isn’t always a TM available. Indeed, the existing translation could be aligned, but this is not always practical or efficient when one is only interested in preparing a quote, not to mention that not everyone is using a Translation Environment Tool to begin with.
So, assuming that there isn’t a TM available, or that it isn’t practical to use one, there is a need for a fairly reliable, quick, and hassle free method for getting the relevant statistics. For that I like to use two built in features of Word: The Reviewing Pane and a Macro.
Please note that I’m using Word 2010. The Reviewing Pane works the same in Word 2007 and 2013, but I’m not sure about Word 2003 or previous versions.

The Reviewing Pane

Word has a nice little and often overlooked feature called the Reviewing Pane, and more specifically, its Revision Summary section. This section shows the number of insertions, deletions, moves (although it is worth noting that a move is counted as one insertion and one deletion, but nevertheless it could be handy to know how much text segments were moved internally) and other edits made to the document.
To bring up the Reviewing Pane:

  1. Switch to the Review tab on the Ribbon.
  2. Click the Reviewing Pane button under the Tracking group of the Review tab.

The Review Pane is displayed on the left (or right if Word is used with a RTL interface language), with the Revision Summary section showing the number of insertions, deletions, and moves.
Revision Summary section of the Reviewing Pane

The Revision Summary section (marked by the red rectangle) of the Reviewing Pane showing the number and types of edits made

This data is important but incomplete. It is incomplete because one insertion could add one word or any number of words to the document, and therefore the revision statistics must be supplemented by the word count statistic to provide a more accurate and reliable estimation of the work involved.

The Track Changes Statistics Macro

The easiest way to get the revision word count is probably using a macro. I thought that such a macro is readily available, but I was wrong. A quick web search have produced several resources, including this great article by Emma Goldsmith in her Signs & Symptoms of Translation blog. That macro counts only the insertions word count, and although that is generally enough because the more important word count to have is the one for the insertions (for the deletions the number of instances is usually more significant), I still prefer to have a more complete set of statistics available. So, I sat down to write one, and a few hours later…I failed! it didn’t work.
Luckily, when I went back online to search for some hints as to why some of the commands aren’t working, I’ve stumbled upon the full solution in an article by Allen Wyatt of Allen Wyatt’s Word Tips.
Mr. Wyatt was kind enough to agree to share his code in this article, and I thank him for that.
The Code for for the Track Changes Statistics Macro (last updated: November 2015):

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

Note: GetTCStats (in the first line of code) is the name of the macro. It could be renamed as long as the new name contains up to 80 letters or numbers (without symbols or spaces) and begins with a letter, as per Word’s macro name limitations.

When running this Macro, a small window pops up and displays the word and character counts of the insertion and deletions.

Track Changes Statistics Window
The Track Changes Statistics results window showing the word and character counts of the revisions

Final Thoughts

Figuring out how much to charge for updating an existing translation when the changes in the source are indicated by the Track Change feature is somewhat of a challenge. The word count alone doesn’t account for the time and effort required for locating the edits in the source and target document, and therefore a more complete set of statistics is needed.
When no TM is available, or when it is not practical to create or use one, I think that the method described in this article for getting the revision summary (i.e. the number of insertions, deletions, and moves that can affect the complexity level of the project) and the word count statistics is a fairly simple, quick, and reliable one.
It is always a good idea to follow-up and visually inspect the document to determine how many of the insertions are also deletions (i.e. text replacements) and what is the average segment size. Working with larger segments of text is usually easier than working with large number of edits that consist of individual words or short sentences.

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookShare on RedditEmail this to someone

31 Comments

  1. Thank you so much ! This is a very useful macro and it works perfectly (altough I had to try a couple of times but I blame it on the fact that I never created a macro before). You kind of made my day.

    1. Thank you Laurence for taking the time to comment.
      I’m glad that you have found the article and Macro useful. Working with documents with tracked changes is a topic that is not often discussed nor receiving the attention that I think it deserves, so I thought to share my experience and method.

    2. I am also trying to record a macro for the first time. But probably I do something wrong. When I run it I get a copy of the code and not the box with statistics. I would appreciate a lot if you can help!

      1. Hi Cristina,
        Open the editor (ALT+F11 or View > Macros > View Macros > Create) and paste the code from the article, replacing the ‘Sub [Name]’ and ‘Sub end’ commands in the editor windows. Just make sure that in the VBA Editor you select the Normal template from the left upper pane.
        Then you should be able to run it from your macro list (View > Macros > View Macros).

        Alternatively, download this this macro export file, and import it into the VBA Editor: ALT+F11 > Make sure the Normal template is selected on the left pane > File > Import file.

        1. Hi Shai,

          Very grateful for the help. Got this macro working.

          (It is never too late to realize that I was taken for a ride by an agency since years. )

          Million thanks.

  2. It’s better to include in your count all the words of a segment that have been modified, since you often need to edit the entire senrtence. Accept all deletions analyse your file and add the words in the No match and the Fuzzy match and you will get a fair esimation of the work you need to do.

    1. Thank you for your comment, Samuel.
      Your way is certainly another option to go about this.
      I think the macro is a very straightforward, quick, and easy way to get the statistics at a glance, especially if you are not using a translation environment tool.

  3. Hello! Many thanks for this very interesting article. I tried to install the macro, but since I have never done so before, I tried to follow the instructions you provided Cristina with with no success. Also, I tried to download the macro export file but can’t find the VBA Editor as the shortcut you indicated does not seem to work on my pc (I tried both my Italian and Spanish computers). I’d be grateful if you could help. Many thanks in advance.

    1. Hello Lucio and thank you for your comment.

      Following your comment I noticed a mistake in my reply to Cristina. The correct shortcut for launching the VBA editor is ALT+F11 and not Shift+F11 as I initially wrote. Sorry about that, and thank you for bringing it to my attention.

      I hope that now you will be able to run the macro, but if not, let me know.

  4. Hi this is very helpful article. i tried to use it on a large word file but it takes forever and the program does not respond in windows. i tried it on mac and it shows error 5852 in word 2011 for mac. is there any other solution? thank you

    1. Hi Selenge,

      I can’t test this on Word 2011 for MacOS, but perhaps the error message indicates that the code needs to be adapted to the the way Word for MacOS works.

      In Windows it should work, though. Did you open the file from an email or first saved it to your system? If you tried to open the file from an email and then run the macro, please try to save it first to the a local folder, and then try to run this macro again.

      Can you share the file?

      1. Hello Shai,
        I have the exact same problem as Selenge (error 5852), except I work on a Windows environment. The string highlighted by the Debug tool is “Select Case oRevision.Type”. Any suggestions as to how to solve the problem?
        Thanks,

        Martina

        1. Hello Martina,

          Can you please verify in the VB editor that the code appears exactly as below (especially that the last line doesn’t repeat itself):

          Sub GetTCStats()
          '
          ' GetTCStats Macro
          '
          '
          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
          

          What version of Word are you using?

          Can you please try to open a new empty document, add some dummy text (in Word 2007 or newer type ‘=lorem(5)’ without the quotes to quickly create 5 paragraphs of dummy text), make some edits with the Track Changes option turned on, and then try to run the macro again on this file? This is to exclude that the error is due to some issue in a specific document.

          1. Hello Shai,

            Thanks a lot for the Macro! I’m a translator and it has saved me a lot of times!

            I ran into this same error 5852 today trying to count the track changes from a 84 pages document. The document has images and tables with text in it. Some of the changes were performed into the tables, other tables were erased, and there were some images added and deleted too.

            I’ve been using the counter just fine in plain text documents, so I’m guessing this error comes from adding or deleting images or tables while using Track Changes. Does this makes sense?

            I use MS Word 2013 on Windows 8.1 and the error points out to “Select Case oRevision.Type”

            I would really appreciate it if you could help us find out what’s causing this error. I need to give a word count for track changes made to a client tomorrow and going through 84 pages is just nuts…

        2. Hi Martina,

          I would like to thank Shai very much indeed for this macro. I encountered the very same problem but when I copied the whole text and pasted it in a new document, the macro worked perfectly. It is really strange, isn’t it? but it worked!

          Thanks Shai once more

          All the best,

          Hamdy

  5. I regularly work with folders containing Microsoft Word documents with tracked changes.

    Could this macro be modified so that it extracts the Revision Summary (just the values/totals) of all Word documents in a particular folder into an Excel work book.

    The table should contain
    Document name:
    Summary (revisions):
    Insertions:
    Deletions:

    1. This will require a different Macro.

      I’m not sure at the moment how to go about this, but a good place to start would be to ask at Allen Wyatt’s Word Tops.

      You might also want to have a look at DocTools. I’m not sure that it does all that you ask for out-of-the-box, but together with the Track Changes Statistics macro I think you would be able to make it work.

      This is an interesting use case, and I’ll have a look into this. If I will come up with something useful, I’ll update the article with the information.

  6. Thank you very much for this Shai, I managed to create a Macro (importing your link). However, the counting it gives me is not accurate – it is always above the real counting. Is there a way of solving this? I work a lot with documents with track changes, and so far I have to rely on the counting made by the client – not that I have any reason to think that it is inaccurate, but I would prefer to do my own counting.
    Anyway, it was great to find this page, and I look forward to hear more from you.
    Ah, I work with an Imac OSX Yosemite…

  7. Thank you for taking the time to comment,
    Yes, I think the macro is currently a little out of date. I need to look into it again.

    1. Thank you for your comment Cristina.

      It is impossible to say. There isn’t any standard estimation/productivity metric because there are too many parameters involved.
      The entire idea behind counting the new and deleted segments is to minimize the guesswork. Knowing how many words there are to update and how many changes were made (fewer edits throughout the documents, i.e. continuous blocks of new or deleted text, usually mean less effort) should give a relatively reliable estimate as to the effort involved. Of course, just like any other translation work — the number of words is only a general metric for giving a rough general idea about the time and effort involved. The nature of the text, the nature of the edits, the purpose of the document, and more all factor in and could significantly affect the work.

      As a very rough estimate, after determining the word count and the general effort involved — charging around 30% more to account for all the extra effort involved in this type of update work compared to translating a similar new document seems reasonable to me. Once you know that project fee, you can break it down to hours or whatever else you want to quote by (although in my opinion working by the hour should really be an open-ended arrangement and not something quoted in advance).

  8. Is the character count with or without spaces? Would be great if it were with spaces (i.e. a standard line / Normzeil in German)

  9. This is a truly helpful macro that we have been using for years now. However we lately have been unable to do so – we get a MW window from Word 10 with the following message “the macro cannot be found or has been disabled because of your macro security settings” We did check our settings and that should not be the problem. We also verified code in the VB editor as well. We are puzzled. Any help will be appreciated 😉

    1. Thank you for your comment, Maria.

      If the setting in File > Options > Trust Center > Trust Center Settings are correct (to allow all macros), I would check for add-in related issue.

      Start Word in Safe Mode. Press and hold the Control key while double clicking Word’s icon. If the macro works in Safe Mode, and add-on might be the culprit.
      Go to File > Options > Add-ins; there make sure COM Add-in is selected in the dropdown list at the bottom, click Go, and disable any Add-ins one-by-one until you find the culprit.

      If this didn’t help, I would rename the Normal.dotm template (when Word is closed), restart Word and see if it made any difference.

  10. Hi Shai,

    it works perfect, and helped me a lot.
    One question – character count is with or without spaces?…

    Best regards,
    Stefan Pecen, simulta, Bratislava

Leave a Reply