I am facing an issue where I am trying to delete all the headers, but I am deleting the footers as well. I am using WDHeaderFooterPrimary, but the footer is still being deleted. I have moved all the sections to the end of the page for future work on the document.
' remove all sections For i = doc.Sections.Count To 5 Step -1 With doc.Sections(i).Range.Find .ClearFormatting .Text = "^b" .Replacement.ClearFormatting .Replacement.Text = "" .Execute Replace:=wdReplaceAll End With Next'insert section after each page For i = 5 To doc.ComputeStatistics(wdStatisticPages) Selection.GoTo What:=wdGoToPage, Which:=wdGoToLast, Count:=i Selection.InsertBreak Type:=wdSectionBreakContinuous Next' delete shapes For i = 5 To doc.Sections.Count Selection.GoTo What:=wdGoToPage, Which:=wdGoToFirst, Count:=i Set hdr = doc.Sections(i).Headers(wdHeaderFooterPrimary) For Each shp In hdr.Shapes shp.Delete Next Next
How do I remove just the headers?