Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[Word] How to select all deletions and put into commet box

Status
Not open for further replies.

Lukutorma

Technical User
Apr 30, 2014
2
The following code is required to:
1. Find a track change (deletion only)
2. Insert a comment box at the point where the deletion is
3. Put the deleted text inside the comment box
4. Accept the deletion

The result should be a document with no deletions, but which contains comment boxes indicating the deletions at the location where the deletion is suggested so other users can decide what deletions should be made.

The code is as follows:

Sub deletions_to_comments()

Dim rev As Revision, txt As String

ActiveDocument.TrackRevisions = False

'check revisions
For Each rev In ActiveDocument.Revisions
Select Case rev.Type
Case wdRevisionDelete
txt = rev.Range.Text 'the deleted text
Selection.Collapse direction:=wdCollapseStart
Selection.Start = rev.Range.Start
Selection.Comments.Add Range:=Selection.Range, Text:=txt 'comment box
rev.Accept
End Select
Next rev

ActiveDocument.TrackRevisions = True

End Sub

The code is not quite working right. I think it has something to do with the way the selection of the deletion text is done. Any assistance getting the code to work correctly is greatly appreciated.
 
hi,

You have to be careful how you use Selection. I try to minimize its use...
Code:
Sub deletions_to_comments()
    Dim rev As Revision, txt As String
    
    ActiveDocument.TrackRevisions = False
    
    'check revisions
    For Each rev In ActiveDocument.Revisions
        Select Case rev.Type
            Case wdRevisionDelete
                txt = rev.Range.Text 'the deleted text
                [highlight #FCE94F]rev.Range[/highlight].Comments.Add Range:=[highlight #FCE94F]rev.Range[/highlight], Text:=txt 'comment box
                rev.Accept
        End Select
    Next rev
    
    ActiveDocument.TrackRevisions = True
End Sub

Skip,

[glasses]Just traded in my OLD subtlety...
for a NUance![tongue]
 
>The result should be a document with no deletions, but which contains comment boxes indicating the deletions at the location where the deletion is suggested so other users can decide what deletions should be made.

Not quite sure how this is any sort of improvement to the current tracking of changes functionality (and display) in Word. Surely, if you have accepted a deletion, with your method you have to manually reinstate the original if the user decides the deletion should be rejected.
 
Thanks, I tested the suggested code and it looks really good. Greatly appreciated.

The advantage is to have a record of track changes (not just deletions) for multiple users, but that's not obvious from the code segment as I have all other parts of a much larger macro working. Users can be given an option to just have comments and not accept the track changes (ie insertions or deletions), but I will need to now test with the users to see what they prefer, not just what Microsoft force users to adopt. Hopefully it results in a better user experience of Word, or atleast working in a team where team member technical skills varies a lot.
 
>a record of track changes (not just deletions) for multiple users
>Users can be given an option to just have comments and not accept the track changes

Which the built-in feature already does pretty comprehensively (unless you are using a pretty old version of Word).

I appreciate your desire to try and improve/simplify things but, as I said, I can't see how this approach achieves that. Having said that, we haven't seen the rest of your macro, so you can probably safely ignore me ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top