L
Legal Learning
I have the following code that puts in an AutoText entry for a path name in
footers. All footers regardless of how many sections, pages, etc. How do I
delete them?
Dim OSection As Section
Dim oFooter As HeaderFooter
Dim oRng As Range
On Error GoTo ErrorHandler
If Len(ActiveDocument.Path) = 0 Then
ActiveDocument.Save
End If
For Each OSection In ActiveDocument.Sections
For Each oFooter In OSection.Footers
If oFooter.Exists Then
Set oRng = oFooter.Range
With oRng
.Fields.Add oRng, wdFieldAutoText, "rlrfooter", False
.Fields.Update
End With
End If
Next oFooter
Next OSection
Exit Sub
ErrorHandler:
If Err.Number = 4198 Then
MsgBox "Document must be saved before adding footer", _
vbCritical, "Not Saved"
End If
Thanks in advance for any help.
footers. All footers regardless of how many sections, pages, etc. How do I
delete them?
Dim OSection As Section
Dim oFooter As HeaderFooter
Dim oRng As Range
On Error GoTo ErrorHandler
If Len(ActiveDocument.Path) = 0 Then
ActiveDocument.Save
End If
For Each OSection In ActiveDocument.Sections
For Each oFooter In OSection.Footers
If oFooter.Exists Then
Set oRng = oFooter.Range
With oRng
.Fields.Add oRng, wdFieldAutoText, "rlrfooter", False
.Fields.Update
End With
End If
Next oFooter
Next OSection
Exit Sub
ErrorHandler:
If Err.Number = 4198 Then
MsgBox "Document must be saved before adding footer", _
vbCritical, "Not Saved"
End If
Thanks in advance for any help.