Unanswered Word 2007 Side by Side view problem

  • Wednesday, August 08, 2012 8:57 AM
     
      Has Code

    Hi,

    I am creating a word application in word 2007 where at a button click i need to do a Side by Side view of the documents together. Here, the problem is when i am specifying the location of both the documents, then its working, but same operation, i am applying on the active document object, then it starts throwing error message to me "The Requested member of the collection does not exists". 

    Here is the code that I am using:
    
    try
                {
                    Word.Document activeDoc = GlobalData.WdApplication.ActiveDocument;
                    icTP.MapStyles.MapStylesWithDocument mswd = new icTP.MapStyles.MapStylesWithDocument();
                    object missing = System.Reflection.Missing.Value;
                    
                    string styleName = mswd.findStyleDocument();
                    object styleFileName = "C:\\StyleTemplates\\" + styleName.ToString();
                    Word.Document styleDoc = GlobalData.WdApplication.Documents.Open(ref styleFileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
                    
                    object o = activeDoc;
                    styleDoc.Windows.CompareSideBySideWith(ref o);
    
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
    

    Now, then how to do that?

    Thanks


    Shahab Abbasi

All Replies

  • Friday, August 10, 2012 11:02 AM
     
     

    According to MSDN:

    You cannot use the CompareSideBySideWith method with the Application object or the ActiveDocument property.

    I don't know why.

    A possible workaround, which I haven't tried, may be to get the active document's name, and then get the actual Document variable from the wdApplications.Documents collection.