|
楼主 |
发表于 2017-4-16 20:47
|
显示全部楼层
参看了 守柔版主 的一句代码,另辟蹊径,解决了问题,应该是没问题了。页眉页脚这块不如文字好办,达到目的就行了。
***下面是《插入页码-公文一字线》的代码:
- Sub test()
- '插入页码_公文一字线
- On Error Resume Next
- ActiveDocument.StoryRanges(wdPrimaryFooterStory).Frames(1).Cut
- '页码格式设为数字
- With Selection.Sections(1).Headers(1).PageNumbers
- .NumberStyle = wdPageNumberStyleArabic
- .HeadingLevelForChapter = 0
- .IncludeChapterNumber = False
- .ChapterPageSeparator = wdSeparatorHyphen
- .RestartNumberingAtSection = False
- .StartingNumber = 0
- End With
- '插入页码(右侧)
- Selection.Sections(1).Footers(1).PageNumbers.Add PageNumberAlignment:=wdAlignPageNumberRight, FirstPage:=True
- '编辑页码
- ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range.Select
- Selection.MoveEnd Unit:=wdCharacter, Count:=-2
- '页码前后插入一字线
- Selection.TypeText Text:=Chr(-24159)
- Selection.InsertSymbol Font:="宋体", CharacterNumber:=8212, Unicode:=True
- Selection.TypeText Text:=" "
- Selection.MoveRight Unit:=wdCharacter, Count:=1
- Selection.TypeText Text:=" "
- Selection.InsertSymbol Font:="宋体", CharacterNumber:=8212, Unicode:=True
- Selection.TypeText Text:=Chr(-24159)
- Selection.Paragraphs(1).Range.Select
- '宋体、四号
- With Selection.Font
- .NameFarEast = "宋体"
- .NameAscii = "宋体"
- .NameOther = ""
- .Name = ""
- .Size = 14
- .Color = wdColorAutomatic
- End With
- '右缩进
- Selection.ParagraphFormat.CharacterUnitRightIndent = 1.5
- '关闭窗格、恢复页面视图
- ActiveWindow.ActivePane.Close
- ActiveWindow.View.Type = wdPrintView
- End Sub
复制代码 |
|