title: How to iterate and count Revisions in a Word document using C#?
body: <p>I have been looking around for this but couldn't find an answer anywhere, so hope aomeone here can help.</p>
  
  <p>I am doing a WinForms application in C# in wich i use WordApplcation.CompareDocuments to compare two documents and get a result document with the changes marked as Revisions.</p>
  
  <p>This works well and apart from the revisions hiding stuff inside textboxes (wich i don't care about just yet) i get exactly what i want.</p>
  
  <p>So next step is to count how many words got revised - specifically wdRevisionDelete and wdRevisonInsert.</p>
  
  <p>Only problem is final.Revisions is sometimes empty or contains enourmous amounts of data (over 500 words).</p>
  
  <p>i read on the MSDN page for Revisions.Count that document.Revisions won't show all revisions but only ones on main story and that i must use range - but that didn't help.</p>
  
  <p>here's my current code:</p>
  
  <pre><code>using Word = Microsoft.Office.Interop.Word;
  </code></pre>
  
  <p>And</p>
  
  <pre><code>foreach (Word.Section s in final.Sections)
  {
          foreach (Word.Revision r in s.Range.Revisions)
          {
                   counter += r.Range.Words.Count;
                   if (r.Type == Word.WdRevisionType.wdRevisionDelete)
                      delcnt += r.Range.Words.Count;
                   if (r.Type == Word.WdRevisionType.wdRevisionInsert)
                      inscnt += r.Range.Words.Count;
          }
  }
  </code></pre>
  
  <p>final is the Word Document created by WordApplication.CompareDocuments</p>
  
  <p>So, as i said, and according to MSDN, i use range.Revision instead of document.Revision, and go section by section.</p>
  
  <p>Only one document with half a dozen revisions shows none while others show 100's.</p>
  
  <p>So my question is, how to use the Revisions to count added / deleted words.</p>
  
  <p>I have opened the documents that CompareDocuments creates in Word 2007 and the Revisions are correctly marked and can be accepted or rejected inside Word</p>
  
  <p>Any ideias on what i might be overlooking?</p>
  
  <p><strong>EDIT:</strong> I have noticed something odd - when i try to save as txt file the original doc files that are reporting 0 changes although the CompareDocuments marks (correctly) a few, i notice that not all pages get saved to the txt file - that includes all areas with revisions.</p>
  
  <p>I tried converting to txt file using both Word 2007 and LibreOffice 3.3 - both have the same result (lot's of text missing).</p>
  
  <p>Might be related somehow.</p>
  
  <p>Wonder what is wrong with this files.</p>
  
  <p>Any ideas?</p>