WORD VBA 插入页码

Sub 插入页码()

ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = False '关闭奇偶页相同(防止上回启用奇偶页不同后没有关闭此项设置)

With ActiveWindow.ActivePane.View

.SeekView = wdSeekCurrentPageFooter

With Selection

.Expand wdStory

.Font.Size = 9 '字号(小五)

.Font.Name = "楷书" '字体

.ParagraphFormat.Alignment = wdAlignParagraphCenter

.TypeText ""
.Font.Name = "Times New Roman" '字体
.Fields.Add .Range, wdFieldPage
.Font.Name = "楷书" '字体
.TypeText "页 共"
.Font.Name = "Times New Roman" '字体
.Fields.Add .Range, wdFieldNumPages
.Font.Name = "楷书" '字体
.TypeText ""
.ParagraphFormat.Alignment = wdAlignParagraphCenter '页码的位置居右

End With

.SeekView = wdSeekMainDocument '退出页码的编辑(即关闭页眉和页脚工具栏)

End With

End Sub

 

posted @ 2022-11-28 00:21  沭水之虾  阅读(1031)  评论(0编辑  收藏  举报