Share via

Make a macro code for tracker change document highlight but "Run-time error 5852"

Anonymous
2014-07-21T09:58:57+00:00

Dear

I have a tracker change document(total page is 79) which i want to highlight this via Macro code. the code will be listed below.


Sub HighLightTrackInsertions()

Dim oRev As Revision

Dim blTrack As Boolean

blTrack = ActiveDocument.TrackRevisions

ActiveDocument.TrackRevisions = True

For Each oRev In ActiveDocument.Range.Revisions

    If oRev.Type = wdRevisionInsert Then

       oRev.Range.HighlightColorIndex = wdGray50

    End If

Next

ActiveDocument.TrackRevisions = blTrack

End Sub

Sub HighLightTrackDeletions()

Dim oRev As Revision

Dim blTrack As Boolean

blTrack = ActiveDocument.TrackRevisions

ActiveDocument.TrackRevisions = True

For Each oRev In ActiveDocument.Range.Revisions

    If oRev.Type = wdRevisionDelete Then

       oRev.Range.HighlightColorIndex = wdGray50

    End If

Next

ActiveDocument.TrackRevisions = blTrack

End Sub

Sub Macro1()

'

' Macro1 Macro

'

'

End Sub

Sub Macro2()

'

' Macro2 Macro

'

'

    Application.Run MacroName:="HighLightTrackDeletions"

    Application.Run MacroName:="HighLightTrackInsertions"

End Sub


When I run this macro, the result is "Run-time error 5852 requested object is not available."

the bug will be highlight on " If oRev.Type = wdRevisionInsert Then".

Could anyone solve this problem?

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

1 answer

Sort by: Most helpful
  1. Andreas Killer 144.1K Reputation points Volunteer Moderator
    2014-07-22T10:07:54+00:00

    When I run this macro, the result is "Run-time error 5852 requested object is not available."

    the bug will be highlight on " If oRev.Type = wdRevisionInsert Then".

    Could anyone solve this problem?

    We need to see your file, this issue did not occur within a "normal" document.

    Please upload your file (maybe with anonymous data) on an online file hoster like www.dropbox.com and post the download link here.

    Andreas.

    Was this answer helpful?

    0 comments No comments