PDA

View Full Version : Change style of highlighted text



liverpool
12-21-2009, 08:46 AM
Hi

I am using the find and replace in Word to record a macro to find all highlighted text in Yellow and replace the style of the highlighted text to “Default Paragraph font”. The problem is I can not seem to find the option to find highlighted text.

Can anyone help or has a macro to search for highlighted text.

Thanks

Tinbendr
12-21-2009, 09:56 AM
From the Word help files.

This will clear the highlight.
Dim rngTemp As Range
Set rngTemp = ActiveDocument.Range(Start:=0, End:=0)
With rngTemp.Find
.ClearFormatting
.Highlight = True
With .Replacement
.ClearFormatting
.Highlight = False
End With
.Execute Replace:=wdReplaceAll, Forward:=True, FindText:="", _
ReplaceWith:="", Format:=True
End With

I think this will clear the style to normal. (I'm terrible with styles.)

fumei
12-21-2009, 12:32 PM
1. Technically you do not need the explicit numerics of the range.
Dim rngTemp As Range
Set rngTemp = ActiveDocument.Range
works fine.

2. A bit of confusion. You state:
a macro to find all highlighted text but is it highlighted, or is it a Character style?

If it is highlighted, then Tinbendr is correct, use:
.ClearFormatting
.Highlight = True
With .Replacement
.ClearFormatting
.Highlight = False
End With
which searches for highlight, and replaces it with no highlight. This should make the text the style of paragraph.