Hi all,
I have two word documents and two text area in my form. I want two compare two documents and load the original and document with changes in corresponding text areas with highlighting the changes. How to do this? I compared and loaded but it is not highlighting the difference
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Office.Tools.Word;
using System.Data;
using System.Windows.Forms;
using Microsoft.Office.Core;
namespace edit
{
public partial class compare : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application();
wordApp.Visible = false;
object wordTrue = (object)true;
object wordFalse = (object)false;
object fileToOpen = @"C:\Documents and Settings\divyar.DNISC\Desktop\doc12.rtf";
object missing = Type.Missing;
Microsoft.Office.Interop.Word.Document doc1 = wordApp.Documents.Open(ref fileToOpen,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref wordTrue, ref missing,
ref missing, ref missing, ref missing);
object fileToOpen1 = @"C:\Documents and Settings\divyar.DNISC\Desktop\doc5.rtf";
Microsoft.Office.Interop.Word.Document doc2 = wordApp.Documents.Open(ref fileToOpen1,
ref missing, ref wordFalse, ref wordFalse, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
Microsoft.Office.Interop.Word.Document doc = wordApp.CompareDocuments(doc1, doc2, Microsoft.Office.Interop.Word.WdCompareDestination.wdCompareDestinationRevised, Microsoft.Office.Interop.Word.WdGranularity.wdGranularityWordLevel,true, true, true, true, true, true, true, true, true, true, "", false);
Editor1.Content = "hai";
doc.ActiveWindow.Selection.WholeStory();
doc.ShowRevisions = true;
doc.ActiveWindow.Selection.Copy();
string con = doc.Content.Text;
TextBox1.Text = con;
wordApp.Visible = false;
doc1.Close(ref missing, ref missing, ref missing);
doc2.Close(ref missing,ref missing,ref missing);
}
}
}