Programmatically delete or hide comments / track changes in Word 2007?

I was wondering if this is possible? And if so, how?

+3
source share
3 answers

Here is Eric White's post that shows how to delete comments: http://blogs.msdn.com/ericwhite/archive/2008/07/14/using-the-open-xml-sdk-and-linq-to-xml -to-remove-comments-from-an-open-xml-wordprocessing-document.aspx

In short, the code he posted is:

XName commentRangeStart = w + "commentRangeStart";

XName commentRangeEnd = w + "commentRangeEnd";

XName commentReference = w + "commentReference";

mainDocumentXDoc.Descendants()

    .Where(x =>

       x.Name == commentRangeStart ||

       x.Name == commentRangeEnd ||

       x.Name == commentReference)

    .Remove();
+2
source

How about the following:

ActiveWindow.View.RevisionsView = wdRevisionsViewFinal
ActiveWindow.View.ShowRevisionsAndComments = False

This will show the final document without markup.

Note. ActiveWindow is a property of the Word.Application class

EDIT:

OLE Automation, , , , , .

+4

Turn track changes on / off by setting the ActiveDocument.TrackRevisions parameter to True / False.

0
source

Source: https://habr.com/ru/post/1707195/


All Articles