Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


C#
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);
            
           
           
       

           
        }
    }
}
Posted
Updated 18-Jun-13 20:32pm
v2
Comments
Christian Graus 19-Jun-13 2:16am    
How are you loading word documents on to a web site ? You need to post code if you want us to make sense of your question
Member 9762654 19-Jun-13 2:33am    
i have updated my question pls check

hi visit this link


[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900