|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Error 5852 - Requested object not available (highlight tracked changes macro)
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! |
Tags |
macro edit, macro error, macros in word |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Error 5852 when stepping through revisions | kae0088 | Word VBA | 4 | 07-07-2023 02:55 AM |
Run-Time error 5941 The Requested member of the collection does not exist , Please help | chulupa89 | Word VBA | 0 | 03-20-2023 03:07 PM |
PLEASE HELP: Run-time error '5941', The requested member of the collection does not exist | newb | Word VBA | 4 | 06-03-2021 05:11 PM |
vba error (object required) for highlight vowels | gsrikanth | Word VBA | 1 | 04-22-2012 08:55 PM |
vba error (object required) for highlight vowels | gsrikanth | Excel Programming | 1 | 04-18-2012 01:06 AM |