檔案中有三個分節符。但是本人參考網上的一些代碼寫出以下代碼無法實作對三個分節分別進行頁碼編排。請教各位大神如何修改。
sub 頁碼編碼()
Dim mrange As Word.Range
Dim r1 As Range, r2 As Range, r3 As Range
Set r1 = mrange.Sections(1).Footers(wdHeaderFooterPrimary).Range
Set r2 = mrange.Sections(2).Footers(wdHeaderFooterPrimary).Range
Set r3 = mrange.Sections(3).Footers(wdHeaderFooterPrimary).Range
With r1
.Font.Size = 10.5
.Collapse direction:=wdCollapseEnd
.Fields.Add Range:=r1, Type:=wdFieldEmpty, Text:= _
"PAGE \* Arabic ", PreserveFormatting:=True
.Expand unit:=wdSection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
With r2
.Font.Size = 10.5
.Collapse direction:=wdCollapseEnd
.Fields.Add Range:=r1, Type:=wdFieldEmpty, Text:= _
"PAGE \* Arabic ", PreserveFormatting:=True
.Expand unit:=wdSection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
With r3
.Font.Size = 10.5
.Collapse direction:=wdCollapseEnd
.Fields.Add Range:=r1, Type:=wdFieldEmpty, Text:= _
"PAGE \* Arabic ", PreserveFormatting:=True
.Expand unit:=wdSection
.ParagraphFormat.Alignment = wdAlignParagraphCenter
End With
end sub
請各位大神支招
uj5u.com熱心網友回復:
目前只能實作頁碼由第一頁編排到最后一頁,但是其他分節的章節需要自己手動操作才能重新編排。轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/23388.html
標籤:VBA
