Reputation: 91
Is it possible to assign a RGB object to be used as the color for highlighted text in Word?
I know that you can do:
Selection.Range.HighlightColorIndex = wdYellow
But is there something similar where I can choose the specific color that I want instead of choosing one of the 16 default values that word gives you?
Upvotes: 4
Views: 8650
Reputation: 1754
You can use shading, this works also in tables and without VBA.
Option 1: Formatting Selected Text
Option 2: Create Character Based Style
Upvotes: 1
Reputation: 111
Using shading instead of highlighting gives more options for colors, but has two shortcomings: You cannot search and replace with shading the way you can with highlighting, and it's a bit clumsier to use than highlighting because you have to create your desired colors in every document. However, both issues can be resolved as follows:
In general terms, Word 2016, this is what you do:
In a blank document, display the Styles menu by clicking the down arrow on the Home tab Styles area. This is important in making this feature user-friendly.
At the bottom of the Styles menu, click the New Styles icon. Create a new character style based on (underlying properties), which is at the top of the Style Based On list. Give it a descriptive title, such as Shading Blue. Click the Format button at the bottom of the dialog box, select Borders, and then select the Shading tab. In the left side under Fill, create your desired color shade, then on the right side, be sure it applies to Text. Leave everything else blank. Click OK and OK.
Now you will see you have a Shading Blue character style in the Styles menu. To use it, just select the text you want to have a blue background, and click the Shading Blue style.
Create the remaining character styles until you have enough different shades (Aqua, Lilac, Pink, Peach, Yellow, Tan, etc.). IMPORTANT: Be sure to create a character style in the same way, but call it Shading None and apply No Color to the fill.
The good thing about creating the character styles this way is that you can create your colors only once, import the styles into your Normal.dotm template, and have them available for all your documents. You can also search for one character style and replace it with another. You can even search for a shade and replace it with None.
Note that the character style for Shading None is not identical to the highlighting with No Color. If you have colored text that is shaded, and you apply the Shading None style, unfortunately the colored text will revert to the Automatic color (black). So red text will change to black. (No help for that.)
Upvotes: 0
Reputation: 1398
I know shading could be an option but it doesn't work the same (e.g.: if you want to hightlight text in a table it will apply the shade to the whole cell).
So this is what I do when I want to highlight using a custom color (at least on Word 2007, haven't tried newer versions):
Go to shading tool and pick a custom color from "more colors", then apply. It will apply the shade, so undo it by using Ctrl+Z. Select the text to highlight, click on highlighting tool and the custom color will now be available as a "recent color":
Upvotes: 0
Reputation: 166306
You could maybe use shading instead:
With Selection.Font.Shading
.Texture = wdTextureNone
.ForegroundPatternColor = wdColorAutomatic
.BackgroundPatternColor = RGB(255, 0, 0)
End With
Upvotes: 2