替换页眉页脚[word]

Sub 替换页眉页脚()
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close
With ActiveWindow.ActivePane.View
  .Type = wdPrintView
  .SeekView = wdSeekCurrentPageHeader
  Selection.WholeStory
  Selection.Delete Unit:=wdCharacter, Count:=1
  Selection.TypeText Text:="这是替换后的页眉"
  .SeekView = wdSeekMainDocument
End With

WordBasic.ViewFooterOnly
Selection.WholeStory
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.TypeText Text:="这是替换后的页脚"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub

原文地址:https://www.cnblogs.com/Ellen/p/2073885.html