Thread: [Solved] Highlight parent word
View Single Post
 
Old 03-08-2013, 11:59 PM
norgro norgro is offline Windows XP Office 2007
Novice
 
Join Date: Feb 2013
Location: Perh Australia
Posts: 12
norgro is on a distinguished road
Default Highlight parent word


I am creating macros to assist with the teaching of Braille.

I need to create a macro to highlight all words in a document that contain the text "ever".

I thought ".parent" would refer to the word that contained the search text, but it did not seem to work.

Your help would be appreciated.

Norman


My code:
Sub FindEver()
Set oRng = ActiveDocument.Range
' Search document for specified text and highlight parent word.

Selection.HomeKey Unit:=wdStory
With oRng.Find
.Text = "ever"
.Wrap = wdFindStop 'stops at the end of the document
While .Execute
oRng.Characters.Parent.HighlightColorIndex = wdYellow
Wend
End With
End Sub
Reply With Quote