Word macro: change one highlight colour to something else
Аўтар тэмы: Samuel Murray
Samuel Murray
Samuel Murray  Identity Verified
Нідэрланды
Local time: 11:14
Член (ад 2006)
англійская → афрыкаанс
+ ...
Feb 23, 2024

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


 
Aurélien ARPAZ
Aurélien ARPAZ
Local time: 11:14
нямецкая → французская
+ ...
A macro Feb 23, 2024

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


Samuel Murray
CafeTran Trainer
 
CafeTran Trainer
CafeTran Trainer
Нідэрланды
Член (ад 2006)
Yep Feb 23, 2024

https://stackoverflow.com/questions/229865/changing-highlighted-text-to-a-different-color

 
Thomas T. Frost
Thomas T. Frost  Identity Verified
Партугалія
Local time: 10:14
дацкая → англійская
+ ...
Built-in Feb 23, 2024

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
PAS  Identity Verified
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


 
Thomas T. Frost
Thomas T. Frost  Identity Verified
Партугалія
Local time: 10:14
дацкая → англійская
+ ...
Highlight Feb 23, 2024

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
Samuel Murray  Identity Verified
Нідэрланды
Local time: 11:14
Член (ад 2006)
англійская → афрыкаанс
+ ...
ПАЧЫНАЛЬНІК ТЭМЫ
@Hans Feb 23, 2024


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
Samuel Murray  Identity Verified
Нідэрланды
Local time: 11:14
Член (ад 2006)
англійская → афрыкаанс
+ ...
ПАЧЫНАЛЬНІК ТЭМЫ
@Aurélien Feb 23, 2024

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
Dan Lucas  Identity Verified
Вялікабрытанія
Local time: 10:14
Член (ад 2014)
японская → англійская
Updating? Feb 23, 2024

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


CafeTran Trainer
 
Samuel Murray
Samuel Murray  Identity Verified
Нідэрланды
Local time: 11:14
Член (ад 2006)
англійская → афрыкаанс
+ ...
ПАЧЫНАЛЬНІК ТЭМЫ
@Dan Feb 24, 2024

Thanks for the tip.

 
CafeTran Trainer
CafeTran Trainer
Нідэрланды
Член (ад 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.


 
Aurélien ARPAZ
Aurélien ARPAZ
Local time: 11:14
нямецкая → французская
+ ...
A clean doc Feb 24, 2024

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
Stepan Konev  Identity Verified
Расія
Local time: 12:14
англійская → руская
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:

Мадэратар(ы) гэтага форума
Maya Gorgoshidze[Call to this topic]
Prachya Mruetusatorn[Call to this topic]

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 »