Add Section Break & Unlink Headers\Footers

Home Up Odds & Ends Photo Gallery Search Contact Me

 

 

The information in this website is provided without risk or obligation and free of charge.  However, if you have benefitted from my efforts here and would like to make a contribution to help me continue and maintain this work then any donation will be greatly appreciated. Please click the adjacent button to access PayPal.  Thank you.
 

Sections in Word can be fickle (see Word MVP FAQ:  Working with sections ).  One thing that I don't like about the built-in user interface for adding sections is the header and footer of any new section inserted is linked to the previous section header and footer by default and "stays that way" without further user actions.  As shown below, the header text in section two is linked by default to the header text in section one.  While this is feature is very handy for repeating header and footer information in subsequent sections, I think it becomes a nuisance when you want to change part or all of the header/footer text in your new sections. 

Say I want to change the section two header text to:

Seems easy enough, but to my chagrin and the chagrin of countless other Word users, the overall effects can seem disastrous.  My point is illustrated if you go back and see the effect that the change in sections two's header had on section one's header

The cause of this is folly is that headers and footers are linked to the previous header and footer when a new section is added with the user interface (Insert>Break). 

And to complicate matters further, a Word document with sections is sort of like an old fashioned player piano sheet.  While the section one header does not display "Same as Previous," the last section of a document (in our case section two) functions in effect as the previous section to section one.  That is why when sections are linked, changes in subsequent sections can roll through a document changing other section's header and footer text in a seemingly mutant manner ;-) 
Here is a macro that you can use to insert a new section.  The content of the header and footer of the previous section is carried into the new section's header and footer when it is created and then the link is broken.  This allows you to make changes in the new header or footer that won't affect the header and footer of the previous section.
Sub AddSectionAndKillLinkToPrevious()
Dim i As Long
Dim j As Long
Dim oDoc As Word.Document
Dim myRng As Word.Range
Set oDoc = ActiveDocument
Selection.InsertBreak Type:=wdSectionBreakNextPage
'Get the index number of the added section
i = oDoc.Range(0, Selection.Sections(1).Range.End).Sections.Count
With oDoc.Sections(i)
    For j = 1 To 3
        .Headers(j).LinkToPrevious = False
        .Footers(j).LinkToPrevious = False
    Next j
End With
'Note: j provides the constant value to unlink the primary page
'(and the first/even page [if exists]) header/footer in the new section
End Sub
Should you have a need to reestablish the link between headers and footers, you can use:
Sub RelinkSections()
Dim i As Long
Dim j As Long
Dim oDoc As Word.Document
Dim myRng As Word.Range
Set oDoc = ActiveDocument
For i = 1 To oDoc.Sections.Count
    With oDoc.Sections(i)
        For j = 1 To 3
            .Headers(j).LinkToPrevious = True
            .Footers(j).LinkToPrevious = True
        Next j
    End With
Next i
End Sub

See: Installing Macros for instructions on how to set up and use the macros listed above.

See: Setup Menu/Toolbar for instructions on how to run a macro from a menu or toolbar icon.

See: Keyboard Shortcut for instructions on how to assign a macro to a keyboard shortcut.


Looking for something else?

Google