View Single Post
 
Old 10-20-2015, 08:53 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,367
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

As I said, the code was sufficient for a document with one Section. To work with multiple Sections, you'd need code like:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, Sctn As Section, HdFt As HeaderFooter
With ActiveDocument
  For Each Rng In .StoryRanges
    Call FndRepRng(Rng)
  Next
  For Each Sctn In .Sections
    For Each HdFt In Sctn.Headers
      With HdFt
        If .LinkToPrevious = False Then
          Call FndRepRng(HdFt.Range)
        End If
      End With
    Next
    For Each HdFt In Sctn.Footers
      With HdFt
        If .LinkToPrevious = False Then
          Call FndRepRng(HdFt.Range)
        End If
      End With
    Next
  Next
End With
End Sub
 
Sub FndRepRng(Rng As Range)
With Rng.Find
  .ClearFormatting
  .Text = ""
  .Font.ColorIndex = wdBlue
  With .Replacement
    .ClearFormatting
    .Text = ""
    .Font.ColorIndex = wdBlack
  End With
  .Forward = True
  .Wrap = wdFindContinue
  .Format = True
  .Execute Replace:=wdReplaceAll
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote