Macro to Change Font Color in Headers/Footers

  • Thread starter Claudine Jalajas
  • Start date
C

Claudine Jalajas

Good afternoon.

I have a template that has blue text in it alerting the
user to make sure they update that information. I have a
macro on a special menu that updates the document by
doing a simple find/replace all blue font and make it
black. However, for some reason it won't go and update
the headers/footers. Any ideas?

Thanks, Claudine
 
H

Helmut Weber

Hi Claudine,
have a look at this one, and, if you like, think of ways
of improvement or simplification. There are some.
E.g. there are lines of code, that appear twice.
Not too good programming style. One could pack them
into a routine like changecolor(color1, color2, MyRange).
But that's for the purists.
---
Sub Test444()
Dim oDcm As Document ' object document
Dim oRng As Range ' object range
Dim oSct As Section ' object section
Dim oHdr As HeaderFooter ' object header and footer
Set oDcm = ActiveDocument
For Each oSct In oDcm.Sections
For Each oHdr In oSct.Headers
Set oRng = oHdr.Range
With oRng.Find
.Text = ""
.Font.Color = wdColorBlue
.Replacement.Text = ""
.Replacement.Font.Color = wdColorAutomatic
.Execute Replace:=wdReplaceAll
End With
Next
For Each oHdr In oSct.Footers
Set oRng = oHdr.Range
With oRng.Find
.Text = ""
.Font.Color = wdColorBlue
.Replacement.Text = ""
.Replacement.Font.Color = wdColorAutomatic
.Execute Replace:=wdReplaceAll
End With
Next
Next
End Sub
 
C

Claudine Jalajas

This worked GREAT!!!

Thanks so much! I'm a happy, happy person today!

Claudine :)
 

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