LB.
LB.

Reputation: 14112

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

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

Upvotes: 3

Views: 4039

Answers (3)

nlinus
nlinus

Reputation: 651

Here's a post by Eric White that shows how to remove comments: https://web.archive.org/web/20140510093032/http://blogs.msdn.com/b/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 here's the code that he published:

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();

Upvotes: 2

Thierry Dalon
Thierry Dalon

Reputation: 926

Toggle on/off Track Changes by setting ActiveDocument.TrackRevisions to True/False.

Upvotes: 1

Patrick McDonald
Patrick McDonald

Reputation: 65431

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:

This answer is using OLE Automation, on rereading your question this may not be what you're looking for, sorry.

Upvotes: 5

Related Questions