View Single Post
 
Old 12-27-2017, 02:53 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Headers and footers are constituent parts of Sections rather than Pages and there are potentially three headers and three footers for each section. Undoubtedly if there is more information added than will fit on the page, then text flow will cause the text to create new pages within the sections. Without access to the document, it will inevitably be a tad hit or miss, but the following should be close, given the nature of the document - however process a copy of the document! :

Code:
Sub Macro2()
Dim oSection As Section
Dim oHeader As Range
Dim oFooter As Range
Dim oRng As Range
Dim i As Integer
    For i = 1 To ActiveDocument.Sections.Count
        Set oSection = ActiveDocument.Sections(i)
        Set oHeader = oSection.Headers(wdHeaderFooterPrimary).Range
        oHeader.End = oHeader.End - 1
        Set oFooter = oSection.Footers(wdHeaderFooterPrimary).Range
        oFooter.End = oFooter.End - 1
        Set oRng = oSection.Range
        oRng.Collapse 1
        oRng.Text = oHeader.Text & vbCr
        Set oRng = oSection.Range
        oRng.End = oRng.End - 1
        oRng.Collapse 0
        oRng.Text = vbCr & oFooter.Text
        oSection.Headers(wdHeaderFooterPrimary).Range.Delete
        oSection.Footers(wdHeaderFooterPrimary).Range.Delete
    Next i
lbl_Exit:
    Set oRng = Nothing
    Set oFooter = Nothing
    Set oHeader = Nothing
    Set oSection = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote