Hello,
I am looking for a way to easily highlight a selected text with either green or pink without having to click on the highlighter icon, move the mouse over the desired color, and then click. I would like two keyboard shortcuts - one for pink and one for green.
If someone can point me in the right direction or create a macro for me, I would be very grateful.
Thanks![]()
Hi,
you can easily create your own macros for that, using the Word Macro recorder.
1. highlight a word or phrase
2. Start the macro recorder (Tools - Macro - Record new macro)
3. assign the macro a name, define if it should be stored in Normal.dot or the current file, assign a keyboard shortcut (after all this, you'll close the dialogs and end up with a recording icon)
4. format your selected text
5. Stop the macro recorder
Now you have a macro that formats selected text upon pressing the keys you specified.
hth
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
In the alternative, you can click the Fill button, and tear off the Fill Color palette to float on the worksheet. Then you can select any color with a single mouse click.
Microsoft MVP - Excel
Entia non sunt multiplicanda sine necessitate
The macro solution worked great!
However, because I'm a bit picky, I want a different shade of green and pink...
Right now, the macro's code is here:
How can I replace wdPink with hex or some other method in order to specify a color to a great specificity?Code:Sub PinkHighlight() ' ' PinkHighlight Macro ' Highlights the selected text pink. ' Options.DefaultHighlightColorIndex = wdPink Selection.Range.HighlightColorIndex = wdPink End Sub
Hi,
with the highlight you are restricted to the colors you see in the palette (and white).
If you want a larger palette, you could use the background color of the text instead of the highlight functionality. This would open up all the colors in the palette. Something like
You will not be able to undo the color with the Highlight button, though, you'll either have to record another macro to set the background color back to nothing or go through the Format - Borders and Shading dialog.Code:Sub MyLights() With Selection.Font With .Shading .ForegroundPatternColor = wdColorAutomatic .BackgroundPatternColor = wdColorLightGreen End With End With End Sub
The named colors can be found in the Visual basic editor help, just enter "BackgroundPatternColor Property" as the help term and drill down do the wdColor list.
Or, instead of the color name, you can use the RGB() function as in
hthCode:.BackgroundPatternColor = RGB(93, 118, 141)
teylyn
Microsoft MVP - Excel
At Excelforum, you can say "Thank you!" by clicking theicon below the post.
Avoid pie charts with more than two data points. Why? See here (pdf, 559 kb). The only acceptable pie chart is here.
I know this is an old thread but try this for your macro. It toggles between black, blue, and red.
Sub Color_rows()
'
' Color_rows Macro
' Toggle between blue/red/black
'
Select Case Selection.Font.ColorIndex
Case xlColorIndexAutomatic
Selection.Font.ColorIndex = 5
Case 5
Selection.Font.ColorIndex = 3
Case Else
Selection.Font.ColorIndex = xlColorIndexAutomatic
End Select
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks