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.
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.