Word macro: change one highlight colour to something else Thread poster: Samuel Murray
| Samuel Murray Netherlands Local time: 01:16 Member (2006) English to Afrikaans + ...
Hello everyone
I have a file with some text highlighted yellow and some text highlighted red. I want to change the red highlighted text to green highlighted. Do you know of a macro that can do that?
Thanks
Samuel | | |
Hello Samuel,
This macro should do what expected:
Sub SwitchHighlightsColor()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
.Highlight = True
.Forward = True
Do While .Execute(FindText:="", Forward:=True) = True
If r.HighlightColorIndex = wdRed Then
r.HighlightColorIndex = wdGreen
r.Collapse 0
End If
... See more Hello Samuel,
This macro should do what expected:
Sub SwitchHighlightsColor()
Dim r As Range
Set r = ActiveDocument.Range
With r.Find
.Highlight = True
.Forward = True
Do While .Execute(FindText:="", Forward:=True) = True
If r.HighlightColorIndex = wdRed Then
r.HighlightColorIndex = wdGreen
r.Collapse 0
End If
Loop
End With
End Sub
Hope this helps!
[Modifié le 2024-02-23 08:54 GMT] ▲ Collapse | | | |
Click on More to see all options, then Format to specify the formats you want to change and what you want to change them to. You don't need a macro for that. | |
|
|
PAS Local time: 01:16 Polish to English + ... Highlighted text | Feb 23, 2024 |
@Thomas - AFAIK the "More" -> highlighting option only lets you find highlighted text, but does not distinguish between the highlighting colours, nor does it let you change the highlight colour.
@Samuel - OK, I just tried something and you didn't even need to hold my beer
If you want to change [other] colour to [green], change the highlight icon in the Word ribbon to green.
Go the usual route of expa... See more @Thomas - AFAIK the "More" -> highlighting option only lets you find highlighted text, but does not distinguish between the highlighting colours, nor does it let you change the highlight colour.
@Samuel - OK, I just tried something and you didn't even need to hold my beer
If you want to change [other] colour to [green], change the highlight icon in the Word ribbon to green.
Go the usual route of expanding the advanced find/replace.
Choose find highlighted text.
Choose replace with highlighted text.
EDIT
Word will replace any highlighted text to whatever highlight colour you have selected in the ribbon - I just tried it with a couple colours and it seems to work.
[Edited at 2024-02-23 10:04 GMT]
[Edited at 2024-02-23 10:24 GMT] ▲ Collapse | | |
Yes, it looks like it. Maybe one can define it in a style, but that's a little more complicated. Did anyone ask ChatGPT for a solution? | | | Samuel Murray Netherlands Local time: 01:16 Member (2006) English to Afrikaans + ... TOPIC STARTER
This one allows me to change all highlights to green, but not only red to green.
Thomas T. Frost wrote:
Click on More to see all options, then Format to specify the formats you want to change and what you want to change them to. You don't need a macro for that.
You can't define the highlight colour when doing find/replace.
[Edited at 2024-02-23 13:47 GMT] | | | Samuel Murray Netherlands Local time: 01:16 Member (2006) English to Afrikaans + ... TOPIC STARTER
Aurélien ARPAZ wrote:
This macro should do what expected: ...
It does, thanks. Unfortunately Word freezes at around 50 pages or so, so it's nice for smaller documents, but didn't do it for one of my files. And... it had tables with tracked changes in it, so I couldn't split and merge the document. | |
|
|
Dan Lucas United Kingdom Local time: 00:16 Member (2014) Japanese to English
Did you turn off screen updating in the VBA script?
If not, put this at the start:
Application.ScreenUpdating = False
And this at the end:
Application.ScreenUpdating = True
Might help.
Regards,
Dan | | | Samuel Murray Netherlands Local time: 01:16 Member (2006) English to Afrikaans + ... TOPIC STARTER | Another idea | Feb 24, 2024 |
Samuel Murray wrote:
Thanks for the tip.
And if that doesn't solve it, you could cycle through all paragraphs in the document and use the range object of the paragraphs.
And if that doesn't solve it, you could first cycle thru pars 1 to 200, then from 201 to 400 etc. | | |
Samuel Murray wrote:
It does, thanks. Unfortunately Word freezes at around 50 pages or so, so it's nice for smaller documents, but didn't do it for one of my files. And... it had tables with tracked changes in it, so I couldn't split and merge the document.
I'm pretty sure it doesn't depend on the size of the document, but on the nature of the document itself. If it's not clean and finalized, it's quite possible that it's stuck somewhere. The only time the macro didn't work for me was when a highlighted text wasn't properly delimited. | |
|
|
Stepan Konev Russian Federation Local time: 03:16 English to Russian TransTools (provided that there is no hidden text) | Feb 24, 2024 |
If you don't have any text hidden in your file and you have TransTools, you can use the Hide/Unhide Text tool to hide the red highlighted text first.
Then select the green highlighting color in MS Word, press Ctrl+H and replace all hidden text with the same text (leave the 'Replace with' box blank) highlighted in green. This would repaint all your red highlights into green.
Finally, unhide all.
Click to play the gif file below... See more If you don't have any text hidden in your file and you have TransTools, you can use the Hide/Unhide Text tool to hide the red highlighted text first.
Then select the green highlighting color in MS Word, press Ctrl+H and replace all hidden text with the same text (leave the 'Replace with' box blank) highlighted in green. This would repaint all your red highlights into green.
Finally, unhide all.
Click to play the gif file below.

[Edited at 2024-02-24 23:28 GMT] ▲ Collapse | | | To report site rules violations or get help, contact a site moderator: You can also contact site staff by submitting a support request » Word macro: change one highlight colour to something else Protemos translation business management system | Create your account in minutes, and start working! 3-month trial for agencies, and free for freelancers!
The system lets you keep client/vendor database, with contacts and rates, manage projects and assign jobs to vendors, issue invoices, track payments, store and manage project files, generate business reports on turnover profit per client/manager etc.
More info » |
| Pastey | Your smart companion app
Pastey is an innovative desktop application that bridges the gap between human expertise and artificial intelligence. With intuitive keyboard shortcuts, Pastey transforms your source text into AI-powered draft translations.
Find out more » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |