![]() |
|
#1
|
|||
|
|||
|
Hello everyone, I was hoping to get some assistance with an issue I'm having in a Word Document. I have a macro that changes text from wdred to wdblack, but I would like the changes to be tracked so that I can easily identify which parts of the document have been modified. I tried adding "ActiveDocument.TrackRevisions = True" at the beginning of the code, but unfortunately it's not working as expected. Although the text color is changing correctly, I'm unable to identify which parts of the document have been modified, as the document is quite large (200 pages). Here's the code I'm currently using: Code:
Sub Macro1()
Selection.Find.ClearFormatting
Selection.Find.Font.Color = wdColorRed
Selection.Find.Replacement.ClearFormatting
Selection.Find.Replacement.Font.Color = wdColorBlack
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
Remarks: My computer: Windows 10 Microsoft Office 2019 i7-8700 8 GB Ram |
|
#2
|
|||
|
|||
|
Hi! Try using
Code:
ActiveDocument.TrackRevisions = Not ActiveDocument.TrackRevisions |
|
#3
|
|||
|
|||
|
Cross-posted at:How to find all text in wdRed and then change to wdBlack, with track changes? - Eileen's Lounge
For cross-posting etiquette, please read: A Message to Forum Cross-Posters |
|
#4
|
||||
|
||||
|
The Execute ReplaceAll command doesn't track the formatting change so you need to loop that step.
Code:
Sub Macro1()
Dim aRng As Range, aRng2 As Range
ActiveDocument.TrackRevisions = True
ActiveDocument.TrackFormatting = True
Set aRng = Selection.Range
Set aRng2 = aRng.Duplicate
With aRng.Find
.ClearFormatting
.Font.Color = wdColorRed
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchByte = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Do While .Execute = True
aRng.Font.ColorIndex = wdBlack
aRng.End = aRng2.End
Loop
End With
End Sub
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#5
|
|||
|
|||
|
Quote:
|
|
#6
|
|||
|
|||
|
Sorry to jump into an old thread, but I tried out this solution and ran into a problem where the Word document is showing "simple" markup for the tracked changes (ie, just a line on the side of the text) even though it's in "All Markup" mode (which should be underlining the edited text). So it looks like this:
unnamed.png The second and third lines were originally red. As you can see, they've successfully turned black, but they're not underlined the way tracked changes normally work. I've double-checked and confirmed that I'm in "All Markup" mode and not "Simple Markup," and I'm at a loss - does anyone know why the Simple Markup line is showing instead? Despite my user settings, the computer I'm trying to do this on is running Windows 11 and using Office 365. Edit: This was meant to be in response to the solution provided by Guessed: Quote:
Last edited by perdur; 11-20-2024 at 07:02 AM. Reason: Added clarifying information. |
|
#7
|
|||
|
|||
|
Quote:
The solution from user macropod helped me get the text I wanted in tracked changes, so leaving this here in case anyone else stumbles upon this thread with the same issue! |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Word 16/19 change font and outside border color (same color) eg is red change to pink
|
jec1 | Word VBA | 2 | 12-04-2019 11:32 PM |
| Macro to change an RGB table cell shading color to another RGB color | David Matthews | Word VBA | 4 | 05-29-2018 02:45 PM |
Macro in Word to track colour of highlighted text
|
BABZ | Word VBA | 1 | 01-09-2017 10:33 PM |
Macro to change all text color to black in all docx files in a selected folder
|
joewoods | Word VBA | 13 | 05-16-2016 06:29 PM |
| Word macro doesn't change font color | Spideriffic | Word VBA | 8 | 11-04-2015 03:47 AM |