Unlink all fields in the headers and footers of a document

Article contributed by Bill Coan

Dim oField As Field
Dim oSection As Section
Dim oHeader As HeaderFooter
Dim oFooter As HeaderFooter

For Each oSection In ActiveDocument.Sections

    For Each oHeader In oSection.Headers
        If oHeader.Exists Then
            For Each oField In oHeader.Range.Fields
                oField.Unlink
            Next oField
        End If
    Next oHeader

    For Each oFooter In oSection.Footers
        If oFooter.Exists Then
             For Each oField In oFooter.Range.Fields
                 oField.Unlink
            Next oField
        End If
    Next oFooter

Next oSection


Click to view Terms of Use page

Click to view Disclaimer page