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
生命在于运动,智慧在于学习!