#1
|
|||
|
|||
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" |
#2
|
||||
|
||||
Ordinarily, one would have the same footer on each page. Consequently, changing the number on one page would cause them all to display that number. Assuming your document doesn't have Section breaks between the pages with the footers unlinked (which - as you observe - is a 'pain' to do), all you need do is insert a PAGE field in the first cell and a NUMPAGES field in the second. No code required.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
footers, page numbers, word vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Page number shows up as { PAGE } instead of number and question about area allowed for footer | dw85745 | Word | 3 | 01-16-2022 03:19 PM |
Table of content to include a page number comprising Section and page number | Allen001 | Word | 2 | 11-25-2019 05:38 AM |
Don't want page number or date in footer on first page, do want graphic in header. | dianahbr | Word | 2 | 02-23-2018 09:25 AM |
Table adding cells to previous page with room still on current page. | gedet | Word | 1 | 01-03-2018 10:35 AM |
Total Page number incorrect in the first page footer | mmathisekar | Word | 11 | 06-16-2016 06:00 AM |