Subtotalling pages in a table extending over more than 1 page

B

B Nash

Would anyone know how to create a macro to subtotal a
number of pages at the foot of each page in a table which
extends over a number of pages. I have been manually
breaking the page into sections, inserting a bookmark
named Table1, Table2 etc at the top of each page and then
using a footer in which I use the Table formula to total
the cells in the table number of that page. I would like
to create a macro which would go through each page and
insert a variable bookmark at the top of each page which
would be based on the page number eg, on page 4 the macro
would insert a bookmark called Table4, etc. There are a
different number of rows on each page as the information
in each row can be of different lengths so I cannot based
the total on a particular row number.
Thanks for any assistance.
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < B Nash > écrivait :
In this message, < B Nash > wrote:

|| Would anyone know how to create a macro to subtotal a
|| number of pages at the foot of each page in a table which
|| extends over a number of pages. I have been manually
|| breaking the page into sections, inserting a bookmark
|| named Table1, Table2 etc at the top of each page and then
|| using a footer in which I use the Table formula to total
|| the cells in the table number of that page. I would like
|| to create a macro which would go through each page and
|| insert a variable bookmark at the top of each page which
|| would be based on the page number eg, on page 4 the macro
|| would insert a bookmark called Table4, etc. There are a

This should get you started:
'_______________________________________
Sub InsertBmEachPage()

Dim PageRg As Range
Dim StartRange As Range
Dim PageCount As Long
Dim MyCount As Long

PageCount = ActiveDocument _
.BuiltInDocumentProperties(wdPropertyPages)
MyCount = 0

Set StartRange = Selection.Range

Selection.HomeKey wdStory

With ActiveDocument

Do While MyCount < PageCount

MyCount = MyCount + 1
Set PageRg = .Bookmarks("\Page").Range
.Bookmarks.Add "Table" & MyCount, _
PageRg.Words(1)
Selection.GoToNext wdGoToPage

Set PageRg = Nothing

Loop

End With

StartRange.Select
Set StartRange = Nothing

End Sub

'_______________________________________

|| different number of rows on each page as the information
|| in each row can be of different lengths so I cannot based
|| the total on a particular row number.
|| Thanks for any assistance.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top