|
本帖最后由 jyh-3777 于 2021-1-14 23:05 编辑
以下为录制宏代码,为奇偶页页码设置不一样,如多页可以,但只有一页运行就会出错,请问如何修改。
Sub A_国标页码()
Call 删除页脚内容
If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
ActiveWindow.Panes(2).Close
End If
If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
ActivePane.View.Type = wdOutlineView Then
ActiveWindow.ActivePane.View.Type = wdPrintView
End If
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
With Selection.HeaderFooter.PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = False
.StartingNumber = 0
End With
With ActiveWindow.ActivePane.View
.SeekView = wdSeekCurrentPageFooter
With Selection
.Expand wdStory
.Font.Size = 14 '字号
.Font.Name = "宋体" '字体
End With
ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = True
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
With Selection
.ParagraphFormat.Alignment = wdAlignParagraphRight
.TypeText "- "
.Fields.Add Selection.Range, wdFieldEmpty, "PAGE \* Arabic ", True
.TypeText " -"
ActiveWindow.ActivePane.View.NextHeaderFooter
With Selection
With Selection
.Expand wdStory
.Font.Size = 14 '字号四号
.Font.Name = "宋体" '字体
End With
.TypeText "- "
.Fields.Add Selection.Range, wdFieldEmpty, "PAGE \* Arabic ", True
.TypeText " -"
End With
End With
End With
With ActiveWindow.ActivePane.View
.SeekView = wdSeekMainDocument '退出页码的编辑(即关闭页眉和页脚工具栏)
End With
End Sub
补充内容 (2021-8-1 08:54):
需要设置页码奇偶页不同,以上代码超过两页可以,单页不可以 |
|