View Single Post
 
Old 06-08-2021, 02:49 PM
Guessed's Avatar
Guessed Guessed is offline Windows 10 Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,164
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I don't know how to convert VBA code to Python but this should give you an idea on how you could copy the headers and footers into the body of the document.
Code:
Sub HFExtractor()
  Dim aSect As Section, aHF As HeaderFooter, aRng As Range
  For Each aSect In ActiveDocument.Sections
    For Each aHF In aSect.Headers
      Set aRng = aSect.Range
      aRng.Collapse Direction:=wdCollapseEnd
      aRng.FormattedText = aHF.Range.FormattedText
    Next aHF
    For Each aHF In aSect.Footers
      Set aRng = aSect.Range
      aRng.Collapse Direction:=wdCollapseEnd
      aRng.FormattedText = aHF.Range.FormattedText
    Next aHF
  Next aSect
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote