1工作说明

1.1标题设置:右上/第n页,共m页

1.2设置页脚:中、文档名称;左下n/m页

设置1.3页边距。

1.4设置段落格式

2程序代码

Sub设置页眉和页脚边距和段落()

If Ac wdPaneNone Then Ac(2)。Close

标题设置

With Ac

.Type=wdPrintView

.seek view=wdseekcurrentpageheader

单元欧共体

Selecunit :=wdcharacter,count :=1

With AC (1)。headers (wdheaderfooterprimary)

Set RNG=。Range

Rng。Text='我的'

Rng。Collapse wdCollapseEnd

Acrng、wdfieldpage、“页面”

Set RNG=。Range

Rng。Collapse wdCollapseEnd

Rng。Text='页面/总计'

Rng。Collapse wdCollapseEnd

Acrng、wdfieldnumpages、“页面”

Set RNG=。Range

Rng。Collapse wdCollapseEnd

Rng。Text='页'

.Range。Fields.Update

.range . paragra=wdalignparagraphright

隐藏标题的水平线。

.range.borders (wdborderbottom)。visible=false

End With

.SeekView=wdSeekMainDocument

End With

页脚设置

沃德巴

单元欧共体

Selecunit :=wdcharacter,count :=1

Dim GetDocName

GetDocName=Left$,Len)-4)

With AC (1)。footers (wdheaderfooterprimary)

Set RNG=。Range

Rng。Text=GetDocName

Rng。Collapse wdCollapseEnd

Set RNG=。Range

Rng。Collapse wdCollapseEnd

Rng。Text='我的'

Rng。Collapse wdCollapseEnd

Acrng、wdfieldpage、“页面”

Set RNG=。Range

Rng。Collapse wdCollapseEnd

Rng。Text='页面/总计'

Rng。Collapse wdCollapseEnd

Acrng、wdfieldnumpages、“页面”

Set RNG=。Range

Rng。Collapse wdCollapseEnd

Rng。Text='页'

.Range。Fields.Update

.range . paragra=wdalignparagraphright

End With

交流电。SeekView=wdSeekMainDocument

设置页边距和页眉页边距

With Ac

.TopMargin=CentimetersToPoin)

.BottomMargin=CentimetersToPoin)

.LeftMargin=CentimetersToPoin)

.RightMargin=CentimetersToPoin)

.header distance=centimeter stopoints(1)

.footer distance=centimeter stopoin)

End With

Ac=0

段落格式,段落后间距0.5行

单元欧共体

With Selec

.LineUnitAfter=0.5

End With

Selecunit :=wdstory,extend :=wsextend

End Sub

流程运行效果如下:

相关推荐