Find and replace across all section headers in a long document

I have a long, non-English, Word document with more than an hundred sections and unique headers. 

Now, I must employ the new Unicode fonts available in Windows 8.1, which entails finding and replacing some characters.

How can one find and replace across all headers in such a long document, without having to click into 100+ headers?

By default, Word uses the Header style for text in headers. Just modify the font of that style. In the Apply Styles pane (Ctrl+Shift+S), type in Header and then click Modify. Specify the font you want and click OK.
Stefan Blom
Microsoft 365 Word MVP since 2005
Volunteer Moderator (Office)
MS 365, Win 11 Pro
~~~~
Please note that I do not work for Microsoft
MVP program info: https://mvp.microsoft.com/
~~~~

1 person found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

See the article "Using a macro to replace text where ever it appears in a document including Headers, Footers, Textboxes, etc.” at:

http://www.word.mvps.org/FAQs/MacrosVBA/FindReplaceAllWithVBA.htm

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Using StoryRanges (as per the link) with Find/Replace in headers & footers is unreliable in multi-section documents. My preferred approach is along the lines of:

Sub Demo()
Application.ScreenUpdating = False
Dim Rng As Range, Sctn As Section, HdFt As HeaderFooter, Fnd As String, Rep As String
Fnd = "Find Text": Rep = "Replace Text"
With ActiveDocument
  For Each Rng In .StoryRanges
    Select Case Rng.StoryType
      Case wdPrimaryFooterStory, wdFirstPageFooterStory, wdEvenPagesFooterStory, _
        wdPrimaryHeaderStory, wdFirstPageHeaderStory, wdEvenPagesHeaderStory
      Case Else
        Call RngFndRep(Rng, Fnd, Rep)
    End Select
  Next
  For Each Sctn In .Sections
    For Each HdFt In Sctn.Headers
      With HdFt
        If .LinkToPrevious = False Then
          Call RngFndRep(HdFt.Range, Fnd, Rep)
        End If
      End With
    Next
    For Each HdFt In Sctn.Footers
      With HdFt
        If .LinkToPrevious = False Then
          Call RngFndRep(HdFt.Range, Fnd, Rep)
        End If
      End With
    Next
  Next
End With
Application.ScreenUpdating = True
End Sub

Sub RngFndRep(Rng As Range, Fnd As String, Rep As String)
    With Rng.Find
      .ClearFormatting
      .Replacement.ClearFormatting
      .Format = False
      .Forward = True
      .Wrap = wdFindContinue
      .Text = Fnd
      .Replacement.Text = Rep
      .MatchCase = True
      .MatchAllWordForms = False
      .MatchWholeWord = False
      .MatchWildcards = False
      .Execute Replace:=wdReplaceAll
    End With
End Sub

Cheers
Paul Edstein
(Fmr MS MVP - Word)

11 people found this reply helpful

·

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes, that worked! Thanks for your reply. You saved me hours of tedious labour.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes, this worked for me, saving me hours of tedious labour. Somehow my earlier reply to you gut stuck under another reply that may have worked, had I tried it.

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

Yes, this worked for me, saving me hours of tedious labour.


Thanks for the follow-up!

Stefan Blom
Microsoft 365 Word MVP since 2005
Volunteer Moderator (Office)
MS 365, Win 11 Pro
~~~~
Please note that I do not work for Microsoft
MVP program info: https://mvp.microsoft.com/
~~~~

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

By default, Word uses the Header style for text in headers. Just modify the font of that style. In the Apply Styles pane (Ctrl+Shift+S), type in Header and then click Modify. Specify the font you want and click OK.

All the replies to my query proved informative and helpful. Stephan's simple solution met my need, this time. Thanks, all!

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 26, 2023 Views 8,272 Applies to: