Word macro: change one highlight colour to something else Аўтар тэмы: Samuel Murray
| Samuel Murray Нідэрланды Local time: 11:14 Член (ад 2006) англійская → афрыкаанс + ...
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: 11:14 польская → англійская + ... 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 Нідэрланды Local time: 11:14 Член (ад 2006) англійская → афрыкаанс + ... ПАЧЫНАЛЬНІК ТЭМЫ
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 Нідэрланды Local time: 11:14 Член (ад 2006) англійская → афрыкаанс + ... ПАЧЫНАЛЬНІК ТЭМЫ
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 Вялікабрытанія Local time: 10:14 Член (ад 2014) японская → англійская
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 Нідэрланды Local time: 11:14 Член (ад 2006) англійская → афрыкаанс + ... ПАЧЫНАЛЬНІК ТЭМЫ | 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. | |
|
|
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 TM-Town | Manage your TMs and Terms ... and boost your translation business
Are you ready for something fresh in the industry? TM-Town is a unique new site for you -- the freelance translator -- to store, manage and share translation memories (TMs) and glossaries...and potentially meet new clients on the basis of your prior work.
More info » |
| 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 » |
|
| | | | X Sign in to your ProZ.com account... | | | | | |