I need to convert tracked changes in Microsoft Word into actual text with the underline/strikethrough. I have had difficulties in dealing with tracked changes with cross-references.
For instance, if a cross reference is updated, from paragraph 5 to 6, it would appear as "65" [the 6 is underlined, but stackoverflow doesn't have that formatting option] I want to retain the 5 as raw text only, but keep the 6 as a cross-reference field.
I've gotten as far as the following macro which will do what I want if the cross reference has been /replaced/ with a new cross reference. However, it still does not work properly if the cross reference was only updated. Any help would be greatly appreciated:
Sub TypeAndStrike()
Dim chgAdd As Word.Revision
Dim Colour
Colour = RGB(255, 0, 0) ' Set the color to change the changes to.
'PD Colors: Black (0, 0, 0), Red (255, 0, 0), Green (0, 255, 0), Blue (0, 0, 255), Brown (165, 42, 42)
Dim SkipNext As Integer
' disable tracked revisions.
If ActiveDocument.Revisions.Count = 0 Then
MsgBox "There are no revisions in this document", vbOKOnly
Else
ActiveDocument.TrackRevisions = False
For Each chgAdd In ActiveDocument.Revisions
If chgAdd.Type = wdRevisionDelete Then ' It's a deletion, so make it strike through and then reject the change (so the text isn't lost).
SkipNext = 0
chgAdd.Range.Select ' move insertion point
chgAdd.Range.Font.StrikeThrough = True
chgAdd.Range.Font.Color = Colour
For Each testRange In Selection.Range.Fields ' Replace cross-refs with >text
testRange.Select
If Selection.Range = chgAdd.Range Then
SkipNext = 1
End If
Selection.TypeText Text:=Selection.Text
Next
If SkipNext = 0 Then
chgAdd.Range.Select
chgAdd.Reject
End If
ElseIf chgAdd.Type = wdRevisionInsert Then ' It's an addition, so underline it.
chgAdd.Range.Font.Underline = wdUnderlineSingle
chgAdd.Range.Font.Color = Colour
chgAdd.Accept
Else
chgAdd.Range.Select ' move insertion point
End If
Next chgAdd
End If
End Sub