Reply
 
Thread Tools Display Modes
  #1   Report Post  
Peter
 
Posts: n/a
Default Finding higlights with a specific color

Hello guys:

Let's say I have a doc with text highlighted in 3 different colors: yellow,
red, and green. I have to replace the font of the text higlighted in green
(from auto[black] color to white).

How can I find those green highlights (using the Find and Replace box OR a
macro; or better yet, both ways)?

Thank you for your ideas,

Nelson


  #2   Report Post  
Dawn Crosier
 
Posts: n/a
Default

Nelson -

You don't mention which version of Word you are using, but this
macro
code has been tested with Word 2003.

You can use the Find and Replace dialog to find Highlighting in
general - however not to find a specific color of highlighting.
To find highlighting in General:
1. Open the Find and Replace dialog box. (CTRL+F)
2. Click the More button to expand the dialog box. (ALT+M)
3. Make sure your cursor is still in the Find What text box.
4. Click the Format button. (ALT+O)
5. Select Highlight from the list. Notice that below the Find
What
box, it now shows Highlight.
6. Click into the Replace box.
7. Click the Format button (ALT+O)
8. Select Font from the list.
9. Adjust the Font Color as appropriate.
10. Close out of the Font dialog box.
11. Find and Replace as usual.

However, if you want to do something special to certain colors of
highlight as given in your example, then you will want to use a
macro.
The difficulty that you will have is that you will have to know
the
word constants for the colors you are looking for and edit the
code as
appropriate. Here is the listing of Word Color Constants From
Help:

HighlightColorIndex Property

Returns or sets the highlight color for the specified range.
Read/write WdColorIndex.

Applies to one of the following WdColorIndex constants.
wdByAuthor
wdAuto
wdNoHighlight
wdBlack
wdBlue
wdBrightGreen
wdDarkBlue
wdDarkRed
wdDarkYellow
wdGray25
wdGray50
wdGreen
wdPink
wdRed
wdTeal
wdTurquoise
wdViolet
wdWhite
wdYellow

I developed this code module with the assistance of fellow MVP
Dian
Chapman.

Sub ChangeHighlight()
&
'Purpose: Changes highlight colors in a doc...need to change
'WD color index
'Changes the font color based on selected highlight color
'***********************
'go to top of doc
Selection.HomeKey Unit:=wdStory

'clear previous find
Selection.Find.ClearFormatting
'set search for highlight on
Selection.Find.Highlight = True
'run search
Selection.Find.Execute
'while highlights are still found
While Selection.Find.Found = True
'if highlight is "wdBrightGreen" (color to find) then
'change the wdBrightGreen in the line below to match
the color
'of highlight you desire. Use the
wdColorIndexConstant List
'as inspiration
If Selection.Range.HighlightColorIndex = wdBrightGreen
Then
'change Selected Text Font to White
'Use the wdColorIndexConstant List to change to
the
'appropriate font color
Selection.Range.Font.Color = wdColorWhite
End If
'continue same search
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Execute
'end loop when no more found
Wend
'move back to top of doc when done
Selection.HomeKey Unit:=wdStory

End Sub

If you need assistance with implementing the above code, please
see
http://word.mvps.org/faqs/macrosvba/CreateAMacro.htm .

Let me know how it goes.

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.

"Peter" wrote in message
...
Hello guys:

Let's say I have a doc with text highlighted in 3 different
colors:
yellow,
red, and green. I have to replace the font of the text
higlighted in
green
(from auto[black] color to white).

How can I find those green highlights (using the Find and
Replace
box OR a
macro; or better yet, both ways)?

Thank you for your ideas,

Nelson



  #3   Report Post  
CyberTaz
 
Posts: n/a
Default

Hello Peter or Nelson-

In Word 2003? When you go into the Find/Replace dialog box, click the 'More'
button, then click the Format button & choose 'Highlight'. Don't type
anything in to the Find field.

Click in the Replace box, but don't type any content, then click the Format
button, select 'Font' and set the font color to White & click OK.

AFAIK, however, Find/Replace cannot distinguish one highlight color from
another, so you will still have to find & replace on a 'one-at-a-time' basis
rather than Replace All.

HTH |:)

"Peter" wrote:

Hello guys:

Let's say I have a doc with text highlighted in 3 different colors: yellow,
red, and green. I have to replace the font of the text higlighted in green
(from auto[black] color to white).

How can I find those green highlights (using the Find and Replace box OR a
macro; or better yet, both ways)?

Thank you for your ideas,

Nelson



  #4   Report Post  
Peter
 
Posts: n/a
Default


"CyberTaz" wrote in message
...

AFAIK, however, Find/Replace cannot distinguish one highlight color from
another, so you will still have to find & replace on a 'one-at-a-time'

basis
rather than Replace All.

Thanks for your suggestion, but my problem is exactly this one -- not
finding the highlight color!
I'll try Dawn suggestion.

Regards,

Nelson, from Peter's computer :-)


  #5   Report Post  
Peter
 
Posts: n/a
Default

Hello Dawn:

Thank you for your help. I'll begin to work on your seuggestion. Now I have
something to begin....

Regards,

Nelson


"Dawn Crosier" wrote in message
...
Nelson -

You don't mention which version of Word you are using, but this
macro
code has been tested with Word 2003.

You can use the Find and Replace dialog to find Highlighting in
general - however not to find a specific color of highlighting.
To find highlighting in General:
1. Open the Find and Replace dialog box. (CTRL+F)
2. Click the More button to expand the dialog box. (ALT+M)
3. Make sure your cursor is still in the Find What text box.
4. Click the Format button. (ALT+O)
5. Select Highlight from the list. Notice that below the Find
What
box, it now shows Highlight.
6. Click into the Replace box.
7. Click the Format button (ALT+O)
8. Select Font from the list.
9. Adjust the Font Color as appropriate.
10. Close out of the Font dialog box.
11. Find and Replace as usual.

However, if you want to do something special to certain colors of
highlight as given in your example, then you will want to use a
macro.
The difficulty that you will have is that you will have to know
the
word constants for the colors you are looking for and edit the
code as
appropriate. Here is the listing of Word Color Constants From
Help:

HighlightColorIndex Property

Returns or sets the highlight color for the specified range.
Read/write WdColorIndex.

Applies to one of the following WdColorIndex constants.
wdByAuthor
wdAuto
wdNoHighlight
wdBlack
wdBlue
wdBrightGreen
wdDarkBlue
wdDarkRed
wdDarkYellow
wdGray25
wdGray50
wdGreen
wdPink
wdRed
wdTeal
wdTurquoise
wdViolet
wdWhite
wdYellow

I developed this code module with the assistance of fellow MVP
Dian
Chapman.

Sub ChangeHighlight()
&
'Purpose: Changes highlight colors in a doc...need to change
'WD color index
'Changes the font color based on selected highlight color
'***********************
'go to top of doc
Selection.HomeKey Unit:=wdStory

'clear previous find
Selection.Find.ClearFormatting
'set search for highlight on
Selection.Find.Highlight = True
'run search
Selection.Find.Execute
'while highlights are still found
While Selection.Find.Found = True
'if highlight is "wdBrightGreen" (color to find) then
'change the wdBrightGreen in the line below to match
the color
'of highlight you desire. Use the
wdColorIndexConstant List
'as inspiration
If Selection.Range.HighlightColorIndex = wdBrightGreen
Then
'change Selected Text Font to White
'Use the wdColorIndexConstant List to change to
the
'appropriate font color
Selection.Range.Font.Color = wdColorWhite
End If
'continue same search
Selection.Find.ClearFormatting
Selection.Find.Highlight = True
Selection.Find.Execute
'end loop when no more found
Wend
'move back to top of doc when done
Selection.HomeKey Unit:=wdStory

End Sub

If you need assistance with implementing the above code, please
see
http://word.mvps.org/faqs/macrosvba/CreateAMacro.htm .

Let me know how it goes.

--
Dawn Crosier
Microsoft MVP
"Education Lasts a Lifetime"

This message is posted to a newsgroup. Please post replies and
questions to the newsgroup so that others can learn as well.

"Peter" wrote in message
...
Hello guys:

Let's say I have a doc with text highlighted in 3 different
colors:
yellow,
red, and green. I have to replace the font of the text
higlighted in
green
(from auto[black] color to white).

How can I find those green highlights (using the Find and
Replace
box OR a
macro; or better yet, both ways)?

Thank you for your ideas,

Nelson





Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can I search for text highlighted in a specific color? Annett Microsoft Word Help 4 August 4th 06 04:04 PM
Word should let me type text in a specific color Gordon_Hogenson Microsoft Word Help 2 July 16th 05 06:06 PM
display one font color on the monitor but print in another lmf001 Microsoft Word Help 1 June 7th 05 03:46 AM
Specific Email Merge w/ Specific Attachements Mark B Mailmerge 9 February 21st 05 06:10 AM
Default background color in Word DuBojangles Microsoft Word Help 3 December 6th 04 01:45 AM


All times are GMT +1. The time now is 11:49 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"