View Single Post
 
Old 05-04-2020, 12:15 PM
alex100 alex100 is offline Windows 7 64bit Office 2016
Advanced Beginner
 
Join Date: May 2020
Posts: 79
alex100 is on a distinguished road
Default Find and change the background color of certain keywords

I'm using the code below to search for highlighted keywords and change their look...

Code:
With ActiveDocument.Content.Find
    .ClearFormatting
    .Font.Shading.BackgroundPatternColor = RGB(235, 214, 214)
    With .Replacement
        .ClearFormatting
        .Font.Bold = True
        .Font.ColorIndex = wdWhite
    End With
    .Execute FindText:="", ReplaceWith:="", _
    Format:=True, Replace:=wdReplaceAll
  End With
Beside making them bold and changing their font color, I'd also like to change their background color. I tried all sorts of ways using the
two codes below, but nothing seemed to work...

Code:
.Font.Shading.BackgroundPatternColor = RGB(0, 0, 0)
.Font.HighlightColorIndex = wdBlack
So, in the end they should be bold, with a white font color and black background.

Changing them this way make them more easily noticeable when printing the document in black and white. That's what I'm using the code for.

Can anyone help me, please?

Thank you,
Alex
Reply With Quote