Follow us on Twitter
Follow us in Facebook
Office Dev Content
SharePoint Dev Content
In this blog post, I will describe the changes to the object model for displaying tracked changes and comments from Microsoft Word 2010 to Microsoft Word 2013 and I explain how to work with the new programmability features relating to tracked changes and comments in Word 2013.
In Word 2010, the View.RevisionsView property helps toggle the display of all tracked changes and comments in the active document by setting the value to one of two possible constants from the WdRevisionsView enumeration: wdRevisionsViewOriginal, and wdRevisionsViewFinal. In Word 2013, this property is replaced by the new RevisionsFilter.View property. RevisionsFilter is a new object added to the object model in Word 2013.
In addition, to toggle display of tracked changes revision marks in Word 2010 you can use the Document.ShowRevisions property, which takes a Boolean. In Word 2013, that property is also hidden, replaced by the new RevisionsFilter.Markup property.
In Word 2010, the Window.ToggleShowAllReviewers method toggles the display of all reviewers’ comments for the specified window. In Word 2013, this method is replaced by the RevisionsFilter.ToggleShowReviewers method. In addition, the View.Reviewers property in Word 2010 is replaced by the RevisonsFilter.Reviewers property.
Also, in Word 2010 the Reviewer.Visible property specifies whether markup from a particular reviewer is displayed. This property remains available in Word 2013, but Word 2013 also adds the RevisionsFilter.Reviewers property, which controls the display of reviewer markup.
In the next section I’ll list all these new objects and members and provide some sample code that shows how to use them.
A new object, RevisionsFilter, and several new members of that object related to the display of tracked changes and comments, and to filtering the display of changes and comments from specific reviewers, have been added to the Word object model in 2013. You can use the View.RevisionsFilter property to return a RevisionsFilter object.
New members have also been added to the existing Comment object to accommodate the new functionality in Word 2013 that allows users to reply to comments.
The new members of the RevisionsFilter object are as follows:
The Markup property gets or sets a WdRevisionsMarkup constant that specifies the extent of reviewer markup displayed in the document. In the context of this setting, the word “markup” includes the revisions themselves, revision marks, and reviewer comments.
The possible values of WdRevisionsMarkup are shown in the following list. These values correspond to those in the Display for Review drop-down list in the Tracking group on the Review tab in the Word user interface (UI), as indicated. Figures 1, 2, and 3 show the results of applying the various settings:
The Reviewers property returns a Reviewers object that represents the collection of reviewers of the active document and all other documents that are open or have been opened on the computer.
The View property returns or sets a WdRevisionsView constant that specifies whether Word uses the original version of the document or the final version as the basis for the revisions shown.
Note: When revisions are visible, and when the MarkupMode property value is set to wdBalloonRevisions, the View property value determines which set of changes are shown in balloons.
The ToggleShowAllReviewers method shows or hides all revisions in a document that contains comments and tracked changes.
Figure 1. The result of setting Markup to wdRevisionsMarkupAll
Figure 2. The result of setting Markup to wdRevisionsMarkupSimple
Figure 3. The result of setting Markup to WdRevisionsMarkupNone
The following code shows how to display all markup in the active document. It also hides the markup and comments from the second reviewer in the collection of reviewers.
Public Sub RevisionsFilter_Example() Dim wrdRevisionsFilter As RevisionsFilter Set wrdRevisionsFilter = ActiveDocument.ActiveWindow.View.RevisionsFilter wrdRevisionsFilter.Markup = wdRevisionsMarkupAll wrdRevisionsFilter.Reviewers.Item(2).Visible = FalseEnd Sub
The new members of the Comment object are as follows.
Returns the parent Comment object for comments that are replies to existing comments. For new, top-level comments, the property returns null.
Returns a CoAuthor object that represents the author of the comment
Returns or sets a Boolean whose value is true if the comment has been marked as complete in the UI. Users can mark a comment as done by choosing a comment and choosing Mark Comment Done on the context menu.
Returns a Comments collection of Comment objects that are children of the specified comment.
Deletes the specified comment and all associated replies.
The following code shows how to get the count of all the replies to a specific comment.
Public Sub GetReplies() Dim myComment As Comment Set myComment = ActiveDocument.Comments(1) Debug.Print myComment.Replies.Count End Sub