Without knowing exactly what is in the two documents it is difficult to judge, but the following will work for a single section. Open the document you want to process and run the macro. Select the template at the prompt.
Option Explicit
'Graham Mayor - https://www.gmayor.com - Last updated - 20 Sep 2020
Sub Macro1()
Dim oDoc As Document, oSource As Document
Dim oRng As Range
Dim sName As String
Dim fDialog As FileDialog
Set oDoc = ActiveDocument
On Error GoTo err_Handler
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
.TITLE = "Select the source template"
.AllowMultiSelect = False
.Filters.Clear
.Filters.Add "Word documents", "*.doc,*.docx,*.docm"
.InitialView = msoFileDialogViewList
If .Show <> -1 Then GoTo err_Handler:
sName = fDialog.SelectedItems.Item(1)
Set oSource = Documents.Open(sName)
If oSource.Sections(1).Headers(wdHeaderFooterFirstPage).Exists Then
If oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Exists Then
Set oRng = oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range
oRng.Collapse 1
oRng.FormattedText = oSource.Sections(1).Headers(wdHeaderFooterFirstPage).Range.FormattedText
End If
End If
If oSource.Sections(1).Headers(wdHeaderFooterPrimary).Exists Then
If oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Exists Then
Set oRng = oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range
oRng.Collapse 1
oRng.FormattedText = oSource.Sections(1).Headers(wdHeaderFooterPrimary).Range.FormattedText
End If
End If
If oSource.Sections(1).Headers(wdHeaderFooterEvenPages).Exists Then
If oDoc.Sections(1).Headers(wdHeaderFooterEvenPages).Exists Then
Set oRng = oDoc.Sections(1).Headers(wdHeaderFooterEvenPages).Range
oRng.Collapse 1
oRng.FormattedText = oSource.Sections(1).Headers(wdHeaderFooterEvenPages).Range.FormattedText
End If
End If
If oSource.Sections(1).Footers(wdHeaderFooterFirstPage).Exists Then
If oDoc.Sections(1).Footers(wdHeaderFooterFirstPage).Exists Then
Set oRng = oDoc.Sections(1).Footers(wdHeaderFooterFirstPage).Range
oRng.Collapse 0
oRng.FormattedText = oSource.Sections(1).Footers(wdHeaderFooterFirstPage).Range.FormattedText
End If
End If
If oSource.Sections(1).Footers(wdHeaderFooterPrimary).Exists Then
If oDoc.Sections(1).Footers(wdHeaderFooterPrimary).Exists Then
Set oRng = oDoc.Sections(1).Footers(wdHeaderFooterPrimary).Range
oRng.Collapse 0
oRng.FormattedText = oSource.Sections(1).Footers(wdHeaderFooterPrimary).Range.FormattedText
End If
End If
If oSource.Sections(1).Footers(wdHeaderFooterEvenPages).Exists Then
If oDoc.Sections(1).Footers(wdHeaderFooterEvenPages).Exists Then
Set oRng = oDoc.Sections(1).Footers(wdHeaderFooterEvenPages).Range
oRng.Collapse 0
oRng.FormattedText = oSource.Sections(1).Footers(wdHeaderFooterEvenPages).Range.FormattedText
End If
End If
End With
lbl_Exit:
Set oDoc = Nothing
Set oSource = Nothing
Set oRng = Nothing
Exit Sub
err_Handler:
Err.Clear
GoTo lbl_Exit
End Sub