4

Question

Is it possible to call Word 2003's Tools > Compare and Merge Documents..." function from C# and to get feedback whether any differences were found or not?

What I have found so far

It is possible to call the functionality like this. But I don't know how to get feedback whether the were any differences found.

    private void CompareAndMergeWithFileB(string fullFilePath)
    {
        string FileName = fullFilePath;
        object MergeTarget = WdMergeTarget.wdMergeTargetSelected;
        object DetectFormatChanges = false;
        object UseFormattingFrom = WdUseFormattingFrom.wdFormattingFromPrompt;
        object AddToRecentFiles = true;

        word.ActiveDocument.Merge(FileName, MergeTarget, DetectFormatChanges, UseFormattingFrom, AddToRecentFiles);
    }
Davide Piras
  • 43,984
  • 10
  • 98
  • 147
Lernkurve
  • 20,203
  • 28
  • 86
  • 118
  • 1
    I don't suppose you could compromise by recording the process as a macro in Word, then tweak that to somehow show you any resulting diffs? – Darth Continent Feb 17 '11 at 18:32
  • @Darth Continent: I am not sure what you mean. I would like to compare hundreds of documents and I am initially only interested in whether the files are identical or not. Same as in a unit test. If they are not identical, I'd like to click a button which opens a file showing the diff file. Both saving and opening the diff file is not a problem. – Lernkurve Feb 17 '11 at 20:10

1 Answers1

5

Absolutely. Once the merge is complete, work with the Revisions collection to extract details about any changes.

Todd Main
  • 28,951
  • 11
  • 82
  • 146