Without knowing what else is in the header/footers or even if there is any additional text in the same paragraph as the page number it is a bit tricky to ensure that only the required field construction is deleted, however the following should work
Option Explicit
Sub Macro1()
Dim objSect As Section
Dim objHF As HeaderFooter
Dim objField As Field
Dim oRng As Range
ActiveWindow.View.ShowFieldCodes = True
For Each objSect In ActiveDocument.Sections
For Each objHF In objSect.Headers
If objHF.Exists Then
For Each objField In objHF.Range.Fields
If objField.Type = wdFieldPage Then
Set oRng = objField.Result
DelPageOf oRng
Exit For
End If
Next objField
End If
Next objHF
For Each objHF In objSect.Footers
If objHF.Exists Then
For Each objField In objHF.Range.Fields
If objField.Type = wdFieldPage Then
Set oRng = objField.Result
DelPageOf oRng
Exit For
End If
Next objField
End If
Next objHF
Next objSect
ActiveWindow.View.ShowFieldCodes = False
lbl_Exit:
Set objSect = Nothing
Set objHF = Nothing
Set objField = Nothing
Set oRng = Nothing
Exit Sub
End Sub
Private Sub DelPageOf(oRng As Range)
oRng.End = oRng.Paragraphs(1).Range.End - 1
If oRng.Fields.Count = 3 Then
oRng.Fields(1).Delete
oRng.Fields(2).Delete
oRng.Fields(1).Delete
oRng.Collapse 1
Do While oRng.Characters(1) = Chr(32) Or _
oRng.Characters(1) = "o" Or oRng.Characters(1) = "f"
oRng.Characters(1).Delete
Loop
End If
lbl_Exit:
Set oRng = Nothing
Exit Sub
End Sub