|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
上面这段代码解决了我反映的问题。很感谢413191246se无私的帮助。
另外,公文的22行新标是有这个规定的。所以我对页面设置做了改动。
Sub PaperSetup()
Dim s As Section
For Each s In ActiveDocument.Sections
With s.PageSetup
If .Orientation = wdOrientPortrait Then
.TopMargin = CentimetersToPoints(3.7)
.BottomMargin = CentimetersToPoints(3.5)
.LeftMargin = CentimetersToPoints(2.7)
.RightMargin = CentimetersToPoints(2.7)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.LinesPage = 22
.LayoutMode = wdLayoutModeLineGrid
Else
.TopMargin = CentimetersToPoints(3)
.BottomMargin = CentimetersToPoints(2.8)
.LeftMargin = CentimetersToPoints(2.5)
.RightMargin = CentimetersToPoints(2.5)
.PageWidth = CentimetersToPoints(29.7)
.PageHeight = CentimetersToPoints(21)
End If
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(2.8)
End With
Next
End Sub
正文也是按对齐网格,单倍行距来安排。这样保证各页下端自动落在下版口(除非页面有不同字号的标题影响,这毕竟少数情况,手动调节)
公文页码是外侧情况。所以对页码做了一个改动。但这个执行结果还没有达到我所希望的效果,因为论坛不能上传视频。我晚上会把我用的页码设置过程录个屏给你看看,用代码如何实现?
以下是暂用的新页码:
Sub 新页码()
ActiveDocument.PageSetup.OddAndEvenPagesHeaderFooter = True
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
With Selection
With .Font
.Name = "Times New Roman"
.Size = 14
End With
.ParagraphFormat.Alignment = wdAlignParagraphRight
.TypeText "— "
.Fields.Add Selection.Range, wdFieldEmpty, "PAGE \* Arabic ", True
.TypeText " —"
End With
ActiveWindow.ActivePane.View.NextHeaderFooter
With Selection
With .Font
.Name = "Times New Roman"
.Size = 14
End With
.TypeText "— "
.Fields.Add Selection.Range, wdFieldEmpty, "PAGE \* Arabic ", True
.TypeText " —"
End With
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
End Sub |
|