|
楼主 |
发表于 2024-6-23 13:42
|
显示全部楼层
本帖最后由 zzpsx 于 2024-6-23 16:27 编辑
我整合如下,不知道哪里还没弄正确。
' 臭冬瓜(QQ:84299244),分享日期:2024.06.19
Option Explicit
Sub 指定参数排版()
'
' 1.图片宽度设置为10厘米
' 2.页边距都设置为2厘米
' 3.添加页码
'
Dim defPicWidth!, defPageMargin!
defPicWidth = CentimetersToPoints(10)
defPageMargin = CentimetersToPoints(2)
Application.ScreenUpdating = False
With ActiveDocument
Dim myInShape As InlineShape
For Each myInShape In .InlineShapes
With myInShape
.LockAspectRatio = msoTrue
.Width = defPicWidth
.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
Next myInShape
Set myInShape = Nothing
With .PageSetup
.TopMargin = defPageMargin
.BottomMargin = defPageMargin
.LeftMargin = defPageMargin
.RightMargin = defPageMargin
.FooterDistance = defPageMargin - CentimetersToPoints(0.5)
End With
.Styles("页眉").Borders.Enable = False
Dim PageFormat As String
PageFormat = "第页 共页"
With Sections.First.Footers(wdHeaderFooterPrimary).Range
.Text = PageFormat
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Move wdParagraph: .Move , -1: .Fields.Add .Duplicate, wdFieldEmpty, "NUMPAGES", False
.Move wdParagraph, -1: .Move: .Fields.Add .Duplicate, wdFieldEmpty, "PAGE", False
End With
End With
Application.ScreenUpdating = True
End Sub
|
|