#1
|
|||
|
|||
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 two codes below, but nothing seemed to work... Code:
.Font.Shading.BackgroundPatternColor = RGB(0, 0, 0) .Font.HighlightColorIndex = wdBlack 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 |
#2
|
||||
|
||||
There is no such property as:
.Font.HighlightColorIndex = wdBlack Moreover, you can't set the HighlightColorIndex that way via Find/Replace. You need to use something like: Code:
Options.DefaultHighlightColorIndex = wdBlack With ActiveDocument.Content.Find .ClearFormatting .Font.Shading.BackgroundPatternColor = RGB(235, 214, 214) With .Replacement .ClearFormatting .Font.Bold = True .Font.ColorIndex = wdWhite .Font.Shading.BackgroundPatternColor = RGB(0, 0, 0) .Highlight = True End With .Execute FindText:="", ReplaceWith:="", Format:=True, Replace:=wdReplaceAll End With
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Wonderful! Thank you very much, Paul!
Alex |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Background color change with drop down list | Wolfin2010 | Excel | 1 | 02-02-2020 11:59 AM |
how to change the selected area background color | wordyg | Word | 0 | 01-28-2019 09:10 PM |
VBA change font color to background color | donaldadams1951 | Word VBA | 6 | 05-31-2018 04:36 PM |
Change excel background color, strange... | sojiro | Excel | 7 | 04-18-2018 10:07 AM |
Can't change table background color in the header in Microsoft Word 2011 | simeon1 | Word | 0 | 10-13-2014 11:07 AM |