PDA

View Full Version : Color words ending with a special characer



Singh_Edm
01-17-2014, 01:23 PM
I have a word document with certain words ending with special characters like a semi-colon (no space between ; and the word). How do I search for those words and color them all at once?
I know how to proceed, don't know how to code. So the code should:


Look for ;
Start selecting backwards from semicolon until a space is found
Color the selection
Return to step 1 untill end of document is reached

gmaxey
01-17-2014, 02:53 PM
This may work:


Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oRng As Word.Range
Set oRng = ActiveDocument.Range
With oRng.Find
.Text = ";"
While .Execute
oRng.MoveStart wdWord, -1
oRng.HighlightColorIndex = wdBrightGreen
oRng.Collapse wdCollapseEnd
Wend
End With
End Sub

Singh_Edm
01-17-2014, 04:01 PM
I replaced the highlight statement with oRng.Font.Color = RGB(255, 69, 0).But as far as rest of the code is concerned, I couldn't have thought of it in years...!
THANKS!!! :hi:

gmaxey
01-17-2014, 07:31 PM
Well some things I think of and some things you think of. Collectively we all think some pretty amazing things. Glad I could help.