For my VSTO Word solution, I need to programmatically โcompareโ two documents side by side. In other words, starting with the code, I need to fulfill the equivalent of clicking the View> Show Side by Side button.
I tried using the CompareSideBySideWith method after loading two documents. An exception is thrown: "The requested collection member does not exist." I am not the first to come across this; see Microsoft (templated, not particularly useful) answers for this thread . MS's reputation ended up scratching her head and giving up.
I even tried to open two empty documents and compare them. There were no exceptions this time, but no comparison happened, and CompareSideBySideWith () returned false.
Document doc1 = this.word.Documents.Add(ref missing, ref missing, ref missing, ref missing);
object doc2 = this.word.Documents.Add(ref missing, ref missing, ref missing, ref missing);
doc1.Windows.CompareSideBySideWith(ref doc2);
Has anyone found a workaround for this? It seems like pretty simple functionality to have in its usual solution.
Note. We need to call the actual Side by Side comparison, not just arrange the windows through Windows.Arrange (). This is partly due to the fact that our feed contains the alias of the "Show next to" button, which does not turn on (pressed) if the actual Side by Side command is not called successfully.
Refresh . In the above example, there was still an exception involving two new documents; Word swallowed the exception because I tried it outside of the try-catch block.
Per Otaku doc2.Windows.Compare(ref doc1), , , .docx .rtf Word 2007.
, RTF, RTF-. , . , RTF-, WordPad, - . Documents.Open() . .docx, ! , View Side by Side RTF, WordPad, .
, , (, Windows.CompareSideBySideWith(). , doc2.Windows.CompareSideBySideWith(ref doc1), Otaku , , doc1 docx, , RTF WordPad. ( , doc2).
2:
, :
doc1.Convert();
.