Finding Highlight

V

vvskpk

Hi
My idea is a kind of crazy. Hope someone has a solution or a macro.
I will be working on many documents which came from proofers with different
highlights for different edits. Something like, Initial capital for all
yellow highlighted words. Use comma after all green highlight. I need to
search all pages where the that highlight is and I probably miss because the
document has lots of pages and single character selected, if any. Likewise,
the edits differ from each highlight.

So now my idea is to use find and replace command, and to find that
particular highlight color so that I can perform changes, maybe atonce if
possible, if not I can correct manually but if the command selects that
color. Highlights will be given from the default colors only. So can we
create a macro for find or find and replace which finds the selected
highlight color?

I apologize for my crazy idea, but I had a hope as the expers are here

Thanks
 
D

Doug Robbins - Word MVP on news.microsoft.com

Use

Selection.HomeKey wdStory
Selection.Find.Highlight = True
With Selection.Find
Do While .Execute(FindText:="", Forward:=True, _
MatchWildcards:=False, Wrap:=wdFindStop, MatchCase:=False) = True
Select Case Selection.Range.HighlightColorIndex
Case wdYellow
'Do something for the Yellow highlight
Case wdRed
'Do something for the Red highlight
'etc
End Select
Selection.Collapse wdCollapseEnd
Loop
End With


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
G

Graham Mayor

You could use something like

Dim oRng As Range
Dim lClr As Long
If ActiveDocument.Content.HighlightColorIndex <> 0 Then
lClr = InputBox("Enter the number of the colour you wish to find" & vbCr
_
& " 1. Black" & vbCr _
& " 2. Blue" & vbCr _
& " 3. Turquoise" & vbCr _
& " 4. Bright green" & vbCr _
& " 5. Pink" & vbCr _
& " 6. Red" & vbCr _
& " 7. Yellow" & vbCr _
& " 8. White" & vbCr _
& " 9. Dark blue" & vbCr _
& "10. Teal" & vbCr _
& "11. Green" & vbCr _
& "12. Violet" & vbCr _
& "13. Dark red" & vbCr _
& "14. Dark yellow" & vbCr _
& "15. 50% gray" & vbCr _
& "16. 25% gray", "Find HiLight")
Selection.HomeKey wdStory
With Selection.Find
.Highlight = True
While .Execute
Set oRng = Selection.Range 'the found highlighted text
If oRng.HighlightColorIndex = lClr Then
'do what you want with the found text
MsgBox oRng.Text
End If
Wend
End With
Else
MsgBox "No Highlighting found."
End If

The macro will find each example of the chosen colour in turn and show the
content in a message box

MsgBox oRng.Text

You can do whatever it is you have to do with the found text in place of the
message box

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top