使用下面的代码,可以设置WORD里面的页眉和页脚的内容。
Dim i As Long
For i = 1 To ActiveDocument.Sections.Count
With ActiveDocument.Sections(i)
.Headers(wdHeaderFooterPrimary).Range.Text = "页眉内容动态添加"
.Footers(wdHeaderFooterPrimary).Range.Text = "页脚内容在这里哦"
MsgBox .Headers(wdHeaderFooterPrimary).Range.Text
End With
Next
最后一句,MsgBox .Headers(wdHeaderFooterPrimary).Range.Text,作用是弹出页眉的内容。