replacement.font.color problem 
Author Message
 replacement.font.color problem

 I have a macro to find and replace styleOld. with styleNew
 I would like to highlight the changed text by turning it red.
Here is the code

 With ActiveDocument.Content.Find
        .ClearFormatting
        .Style = styleOld
        .Format = True
        .Replacement.ClearFormatting
        .Replacement.Style = styleNew
        .Replacement.Font.Color = RGB(255, 0,0)
        .Execute Forward:=True, Replace:=wdReplaceAll, FindText:="",
ReplaceWith:=""
End With

The macro goes through the document changing all instances of styleOld to
styleNew.
Each time it comes to a section within the document containing styleOld it
changes the first paragraph within that section to red, but although it
changes the remaining paragraphs in the section to styleNew they are not
changed to red.

I would be grateful if someone can explain to me why this is happening.
Thanks
Bill



Thu, 11 Nov 2004 15:43:23 GMT  
 replacement.font.color problem
Hi Bill,

Why not define the colour of the font in StyleNew so that it is red?

Please post any response to the newsgroups for the benefit of others who may
also be following the thread.

Hope this helps,
Doug Robbins - Word MVP

Quote:
> I have a macro to find and replace styleOld. with styleNew
>  I would like to highlight the changed text by turning it red.
> Here is the code

>  With ActiveDocument.Content.Find
>         .ClearFormatting
>         .Style = styleOld
>         .Format = True
>         .Replacement.ClearFormatting
>         .Replacement.Style = styleNew
>         .Replacement.Font.Color = RGB(255, 0,0)
>         .Execute Forward:=True, Replace:=wdReplaceAll, FindText:="",
> ReplaceWith:=""
> End With

> The macro goes through the document changing all instances of styleOld to
> styleNew.
> Each time it comes to a section within the document containing styleOld it
> changes the first paragraph within that section to red, but although it
> changes the remaining paragraphs in the section to styleNew they are not
> changed to red.

> I would be grateful if someone can explain to me why this is happening.
> Thanks
> Bill



Thu, 11 Nov 2004 18:27:15 GMT  
 replacement.font.color problem
Hi Doug

Thanks for the suggestion, but I do not have control over styleNew.
I should have made this clearer.
 styleNew and styleOld are chosen from combo boxes listing the document's
styles.
I only want the style change to show up in red so the typist can see where
the document has been changed and do any checking necessary.
Another macro turns all the red back to black once this has been done.
The typist can elect whether or not to go through this step, in other words
she can just make the change without highlighting it in red

Bill



Quote:
> Hi Bill,

> Why not define the colour of the font in StyleNew so that it is red?

> Please post any response to the newsgroups for the benefit of others who
may
> also be following the thread.

> Hope this helps,
> Doug Robbins - Word MVP


> > I have a macro to find and replace styleOld. with styleNew
> >  I would like to highlight the changed text by turning it red.
> > Here is the code

> >  With ActiveDocument.Content.Find
> >         .ClearFormatting
> >         .Style = styleOld
> >         .Format = True
> >         .Replacement.ClearFormatting
> >         .Replacement.Style = styleNew
> >         .Replacement.Font.Color = RGB(255, 0,0)
> >         .Execute Forward:=True, Replace:=wdReplaceAll, FindText:="",
> > ReplaceWith:=""
> > End With

> > The macro goes through the document changing all instances of styleOld
to
> > styleNew.
> > Each time it comes to a section within the document containing styleOld
it
> > changes the first paragraph within that section to red, but although it
> > changes the remaining paragraphs in the section to styleNew they are not
> > changed to red.

> > I would be grateful if someone can explain to me why this is happening.
> > Thanks
> > Bill



Fri, 12 Nov 2004 06:10:49 GMT  
 replacement.font.color problem
Hi Bill,

Unfortunately, you can't change the style and some formatting in the same Find/Replace. You'll have to do two Replaces:
1: syleOld with styleNew,
2: styleNew with  .Replacement.Font.Color = RGB(255, 0,0)

Regards, Klaus
Word MVP



Sun, 14 Nov 2004 19:34:14 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Font color formula problems

2. Change font and font color inside a textbox

3. Change the color of form's caption (background and font color)

4. How to change cell color or font color when data changed

5. How to change cell color or font color when data changed

6. How to maintain Bold font and underline in Text replacement

7. .Replacement.Highlight color choice - how?

8. <font color=red><font size=256>S.O.S.!!!</font></font>

9. Large font and small font problem

10. problem small fonts/large fonts

11. Problem when moving from Small Font to Large Font

12. An annoying problem: small fonts/large fonts

 

 
Powered by phpBB® Forum Software