|
本帖最后由 cunfu2010 于 2017-12-14 10:18 编辑
Sub test()
Dim aSection As Section, i As Byte, aHeaderFooter As HeaderFooter, aField As Field
Application.ScreenUpdating = False
For Each aSection In ActiveDocument.Sections
For i = 1 To 2
For Each aHeaderFooter In IIf(i = 1, aSection.Headers, aSection.Footers)
If aHeaderFooter.Range.Fields.Count > 0 Then
For Each aField In aHeaderFooter.Range.Fields
If aField.Type = wdFieldPage Or wdFieldNumPages Or wdFieldSectionPages Then
aField.Select
Selection.Expand wdSentence
Selection.Delete
End If
Next
End If
Next
Next i
Next
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.Panes(2).Close
ActiveWindow.View.Type = wdPrintView
End If
Application.ScreenUpdating = True
End Sub
此段代码只能删除页脚中的内容,删除不了页脚,代码运行后还有存在页脚的印迹,如何改进,在删除页脚内容的同时,也清除页脚的印迹,或者直接删除页脚?
|
|