As part of post-clean up in some of my templates, I loop through a document, check each field to see if it is a custom document property (wdFieldDocProperty). If it is, I unlink it, then delete all the custom properties. This is working well for the body of the document. See code at the bottom of this post.
Is there an easy way to search through the fields that may be in headers/footers? – Or – Do I have to count sections then check each section for different first page then go into each header and footer? Within my templates, I know where the fields are, but I want to extend this to documents/templates other may have created.
Dim i As Integer
Dim intX As Integer
Dim proDoc As DocumentProperty
intX = ActiveDocument.Fields.Count
For i = intX To 1 Step -1
If ActiveDocument.Fields(i).Type = wdFieldDocProperty Then
ActiveDocument.Fields(i).Unlink
End If
Next
For Each proDoc In ActiveDocument.CustomDocumentProperties
proDoc.Delete
Next