The orignal and final version were being opposite in Word Documents 2010 Comparison API
Hello,
We have encountered a problem with our application. We are using
.NET 3.5SP1 in conjunction with Word 2003 automation to create some
documents word trackchange report on the application side.
The automation works without problems on our developer machines which
run Windows XP and Office 2003. However, in Office 2010, we have a problem:
The Orignal and Final was switched so some text insert will show as delete and delete show as insert.
Our client are not happy with the result. So, any ideas?
Here is the code pieces .
fileNames is a array of word document path, in office 2003, the order are [ "Orignal file", "Final file"]
but I had to switch them to [ "Final file", "Orignal file"] when user using Office 2010...
Is that a feature in office 2010 or it's a know issue?
Word.ApplicationClass wordApp = null;
Word.Document wordDocument = null;
try
{
wordApp = new Word.ApplicationClass();
// wordApp.Visible = false;
foreach (var fileName in fileNames)
{
if (wordDocument == null)
{
Console.WriteLine("Open:" + currentPath + fileName);
var missing = System.Type.Missing;
object fileNameObj = currentPath+fileName;
object confirmConversion = false;
object readOnly = false;
object addToRecentFiles = false;
object revert = true;
object format = Word.WdOpenFormat.wdOpenFormatAuto;
object openAndRepair = false;
object noEncodingDialog = true;
wordDocument = wordApp.Documents.Open(ref fileNameObj, ref confirmConversion, ref readOnly, ref addToRecentFiles, ref missing, ref missing,
ref revert, ref missing, ref missing, ref format, ref missing, ref missing, ref openAndRepair, ref missing, ref noEncodingDialog, ref missing);
wordDocument.RemoveLockedStyles();
}
else
{ //the 2nd or 3rd files
var missing = System.Type.Missing;
object compareTargetCurrent = Word.WdCompareTarget.wdCompareTargetCurrent;
object detectFormatChanges = false;
object ignoreAllComparisonWarnings = true;
object addToRecentFiles = false;
object removePersonalInformation = true;
object removeDateAndTime = false;
Console.WriteLine("Compare with:" + currentPath + fileName);
wordDocument.Compare(currentPath+fileName, ref missing, ref compareTargetCurrent, ref detectFormatChanges, ref ignoreAllComparisonWarnings, ref addToRecentFiles,
ref removePersonalInformation, ref removeDateAndTime);
wordDocument.Save();
}
}
}
catch (Exception ex)
{...}