Wednesday, May 4, 2011

Comparing MS Word documents from within VS2010

Update: This also works with EXCEL file (see PS at the end). 

Many project managers complains that TFS2010/VS2010 CANNOT compare MS Word documents
(which is a bad practice anyway because it not a source code, and should be stored in a document repository where workflow of validation and search engine are present).

I understand that Microsoft spend their efforts in using Sharepoint as a document repository, hence not implementing this functionality in VS2010 / TFS 2010.

This is even more bizarre when knowing that TurtoiseSVN performs that natively !

Here is a trick to have the best of the two worlds : Use TurtoiseSVN from within VS2010, and still keeping TFS2010 as a Source Control.

1. Download and install TurtoiseSVN (it's free),



2. Customize the comparison Tool within VS2010, and instead of the default one, do the following :
Visual Studio > Tools > Options > Source Control >Visual Studio Team Foundation Server > "Configure User Tools..." button

Use the following parameters (adjust your TortoiseSVN's installation folder if required) :
  • Extension: docx
  • Operation: Compare
  • Command: C:\Windows\System32\wscript.exe
  • Arguments: "C:\Program Files\TortoiseSVN\Diff-Scripts\diff-docx.js" %1 %2 //E:javascript


That's it !

Now, do your normal comparison within VS2010, based on the History for example :

After a few scripts running behind the scene to open Word and configure it in a comparison mode, here is the result:

Now you can receive another version of a 200 pages of specifications, and not being  scare you any longer !!
Hope this helps speeding up your work.


PS: This also works with EXCEL (*.xlsx) file, BUT NOT REALLY GOOD, because it compares cell-by-cell and detects too many false positive changes.  
Do do so,
- Open your Program Files\TortoiseSVN\Diff-Scripts folder.
- Duplicate the file diff-xls.vbs into diff-xlsx.vbs
- Create a new comparison as presented at step 2, but this time for the xlsx extension
- Remove the option "//E:javascript" in the arguments,
- Start enjoying Excel comparison within Visual Studio :
   . It presents the 2 files side by side,
   . and highlights in RED the changes.