View Single Post
 
Old 08-13-2022, 01:08 PM
nyconfidential nyconfidential is offline Windows 10 Office 2019
Novice
 
Join Date: Nov 2021
Posts: 4
nyconfidential is on a distinguished road
Default Updating page number in table cells in footer in each page

Hi all - I have several documents that I need to merge together. The merging works fine, but I need to update the page number in each page footer after I am done (the page number and the total page count is stored in 2 table cells in the footer, see attached image - if the document has ten pages and you are on the third page, the first cell will read "3", the second will read "10", etc).

Now, something like the code below works if I put in a loop, but I only if I create a section break on each page (also I have to de-link the footers which is pain).


Code:
ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).range.Tables(1).Cell(1, 1).Range = "3"

ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).range.Tables(1).Cell(1, 2).Range = "10"



ActiveDocument.Sections(2).Footers(wdHeaderFooterPrimary).range.Tables(1).Cell(1, 1).Range = "4"

ActiveDocument.Sections(2).Footers(wdHeaderFooterPrimary).range.Tables(1).Cell(1, 2).Range = "10"
I'm sure there's a better way to do this, anyone have any suggestions? (Note, I have to keep the table cells, those are not allowed to change)
Attached Images
File Type: png word page.PNG (564 Bytes, 12 views)
Reply With Quote