PDA

View Full Version : How to Restart page numbering after 4 pages



khoav2k
04-10-2024, 05:57 PM
VBA WORD, How to start page renumbering after 4 pages?

Aussiebear
04-10-2024, 08:22 PM
Microsoft gives this as an example


With ActiveDocument.Sections(1)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberLeft, _
FirstPage:=True
End With


So what happens if we went with


With ActiveDocument.Sections(5)
.Footers(wdHeaderFooterPrimary).PageNumbers.Add _
PageNumberAlignment:=wdAlignPageNumberLeft, _
FirstPage:=True
End With


Just guessing here, while we wait for those experts who are currently slumbering to come calling.

Chas Kenyon
04-13-2024, 08:33 PM
That adds page numbers, it does not restart the numbering sequence.
Doing that requires a Section break before page 4.
You need to know the Word object model for page numbering before you start trying to code it.
Try creating a scratch document and record a macro that restarts the numbering using the Format Page Numbers dialog and look at the code.

These talk about what is going on in Word.
Numbering Front Matter by Suzanne Barnhill, MVP (http://wordfaqs.ssbarnhill.com/FrontMatterRibbon.htm)
Page Numbers in Word 2007-2021 (365)
(https://www.addbalance.com/usersguide/sections2007.htm#PageNumbers)
Then look at your recorded code in the vba editor to get an idea of the Word objects and methods involved.
How to Modify a Recorded Macro by Jay Freedman (https://wordmvp.com/FAQs/MacrosVBA/ModifyRecordedMacro.htm)