none
Can you INITIATE Word 2010 by passing 2 documents to it for comparison (command line string perhaps)?

    Question

  • I know how to start Word 2010 and choose Compare and select 2 documents.

     

    What I am wondering is whether there is a command line that starts Word 2010 and passes the path to 2 different files for Comparison?

     

    This would be particularly helpful when using advanced Document Management Systems, when you start with lists of documents, rather than starting in an application (ie World)

    Saturday, November 6, 2010 2:04 AM

Answers

  • This can be done through code.  Here's a C# example comparing just the text.

     

    object missing = System.Reflection.Missing.Value;

     

    //create a readonly variable of object type and assign it to false.

     

    object readonlyobj = false;

     

     

    object filename = txtfile1.Text;

     

    //create a word application object for processing the word file.

     

    Word.Application app = new Word.ApplicationClass();

     

    //create a word document object and open the above file..

     

    Word.Document doc = app.Documents.Open(

     

    ref filename, ref missing, ref readonlyobj, ref missing, ref missing,

     

    ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

     

    string filenm = txtfile2.Text;

     

    string nm = txtpath.Text + @"\" + getfilename(txtfile1.Text);

     

    object filesavename = nm;

     

    doc.SaveAs(ref filesavename, ref missing, ref missing, ref missing, ref missing, ref missing,

     

    ref missing, ref missing, ref missing, ref missing, ref missing);

     

    doc.TrackRevisions = true;

     

    doc.ShowRevisions = true;

     

    doc.PrintRevisions = true;

     

     

    doc.Compare(filenm);

     

     

    doc.Close(ref missing, ref missing, ref missing);

     

    app.Quit(ref missing, ref missing, ref missing);

     

    MessageBox.Show("Process complete");


    Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Thanks!
    Adrian
    Microsoft Online Community Support

    • Marked as answer by Sally Tang Thursday, November 11, 2010 1:05 AM
    Tuesday, November 9, 2010 8:52 PM
    Moderator