Hello all,
I am new to using macros in Microsoft word but am familiarizing myself with it.
I want to use a macro to automatically approve all 'tracked changes', and highlight what was changed. Basically, changing 'track changes' to highlights.
Here's the macro I used:
Sub AcceptChangesAndHighlight()
Dim rev As Revision
Dim rng As Range
For Each rev In ActiveDocument.Revisions
Set rng = rev.Range
rng.Revisions.AcceptAll
rng.HighlightColorIndex = wdPink ' Replace 'wdPink' with the appropriate color index
Next rev
End Sub
It worked in most documents but for some reason, this larger doc I'm trying to use it on (18 pages) I keep getting the following error:
Run-time error '5852': Requested object is not available.
When I click 'Debug', it highlights the line: Set rng = rev.Range
As I said, I'm a beginner to this macro stuff but this has been driving me crazy. I feel like I've tried everything I can think of. I tried other macros as well - I tried this one, which someone posted in another forum:
Sub AcceptChangesAlt()
Dim tempState As Boolean
tempState = ActiveDocument.TrackRevisions
ActiveDocument.TrackRevisions = False
Dim index As Long
Dim changeRange As Range
For index = ActiveDocument.Revisions.count To 1 Step -1
Set changeRange = ActiveDocument.Content
changeRange.Start = ActiveDocument.Revisions(index).Range.Start
changeRange.End = ActiveDocument.Revisions(index).Range.End
changeRange.Revisions.AcceptAll
changeRange.Font.Color = 12611584 ' Set font color (change as needed)
Next
ActiveDocument.TrackRevisions = tempState
End Sub
When I use that one, I get the same error, only this time it highlights:
changeRange.Start = ActiveDocument.Revisions(index).Range.Start
Finally, I tried using this macro:
Sub accept_changes()
tempState = ActiveDocument.TrackRevisions
ActiveDocument.TrackRevisions = False
Dim index As Long, Change As Range
For index = ActiveDocument.Revisions.Count To 1 Step -1
Set Change = ActiveDocument.Revisions(index).Range
Change.Revisions.AcceptAll
Change.Font.Color = 12611584
Next
ActiveDocument.TrackRevisions = tempState
End Sub
And I get the same error. Now, it highlights:
Set Change = ActiveDocument.Revisions(index).Range
I'd really appreciate any help here. I have no idea how to go forward to get this macro to work - you all are my last hope!
P.S. I've heard of people talking about a plugin called Zotero that can cause this error with macros. I don't have that plugin.
Thanks in advance for any help!
