Microsoft Interop: Word compare .doc with .docx c#

I’ve built an application that obtains 2 records and after that opens Word to match up changes in between them. If I attempt to compare.doc with.docx it opens simply the.doc in being compatible method as well as doesn’t perform a comparison, it operates perfectly along with 2.docx or 2.doc yet. Right here is the code I make use of to review:

object fileToOpen = (object)rutaVersion1;
  string fileToCompare = rutaVersion2;

  object missing = Type.Missing;

  doc1 = wordApp.Documents.Open(fileToOpen, Visible: true);
  wordApp.ActiveDocument.Compare(fileToCompare, missing, WdCompareTarget.wdCompareTargetCurrent, true, true, false, false, false);

Document comparison isn’t actually my forté, yet … 1) I will expect a *. 3) What’s the problem along with the contrast you’re acquiring in your code/ just how does it contrast from performing it manually?

Got it: 1 、 develop the doc 2 、 loophole all paragraphs add publisher at the best paragraph I located that I can’t add editor when the doctor is create.

I wish to insert an image, at that point a new series and also after that yet another image. The method needs to be actually redoed till all the photos are put. This is my code as of currently which inserts graphics, yet not empty series

Your tip is actually ideal to begin with, nonetheless Word acts a little bit different than expected. I saw, just like you, that nevertheless adding brand-new paragraphs the brand new paragraps might be actually revised despite the fact that you really did not exclusively included Editors to the new paragraph.

So, you need to switch it about, through incorporating every person to the comprehensive file and also working vice versa by removing the publishers coming from the parts that you intend to guard.

When I evaluate in VBA I carry out get a mark-up in the *. doc report. I did alter your code in one (perhaps essential) respect: Rather of wordApp.ActiveDocument.Compare I utilize doc1.Compare. I likewise do not change any type of Window states, however that shouldn’t help make any sort of variation. If that does not help, which variation of Word are you running?

This example reveals you that (I generated a file along with 5 paragraphs to examination) just about the 4th paragraphs may be revised. Undoubtedly you can dynamically make your document and take out the Editors about that.

To give you a tip I developed a little bit of part of VBA code however I make certain you may spin and rewrite the components you require in C#. Details that I loop over the editors erasing all of them one by one rather of using DeleteAll(). I found that utilizing DeleteAll was actually throwing unpredicted exemptions.

Look cautious at the solution, the demo code includes a collection: [ActiveDocument.Content.Editors.Add Word.WdEditorType.wdEditorEveryone] If you run it on an existing page the whole document gets a publisher once more. On existing records you must leave behind that out, and simply remove/add the editors on arrays you desire to change.

points to.doc report, as well as rutaVersion2 to.docx. Using Office365 but having the same issue along with various other Office model. If I manually contrast all of them it operates.

Why can’t you utilize Allow modifications to component of a guarded record?

Leave a Reply

Your email address will not be published. Required fields are marked *