![]() |
|
#2
|
||||
|
||||
|
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 |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to insert page break when copying Excel table into PP? How set headers/footers in PP like Word? | proja | PowerPoint | 0 | 09-16-2015 12:36 PM |
Headers and Footers
|
Kingsmoss | Word | 3 | 04-28-2014 02:43 PM |
Odd and Even Headers/Footers
|
sarineochaos | Word | 1 | 02-04-2014 06:15 PM |
Headers and Footers
|
teza2k06 | Word | 1 | 05-14-2013 11:07 AM |
| Headers and Footers | OverAchiever13 | Word | 1 | 05-27-2010 01:30 PM |