HOWTO: calculate running total and print at end of page/start of nextpage

S

StefanM

Hi all WORD gurus,

I'm using word to print invoices via VBA automation. Currently I use
autotext fields to pass data from my program to WORD 2003. Now I need
to solve one final problem: calculate a running total and print this
at the end of each page (using the page footer?) and at the start of
the following page (using the page header?).

Can this be done in Word or do I need to insert special autotext-
fields to print the running total?
How can I suppress the footer on the last page?

TIA,
Stefan
 
D

Doug Robbins - Word MVP

Better if you show us the code that you are using.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
S

StefanM

Doug,

on Word's side, there is no code involved. I'm using SQLWindows (Gupta/
Unify) and the ActiveX-interface to Word to create the invoice. The
invoice is based on a DOT-file with all the autotext fields defined
and the basic layout and text of the invoice. Up to now I had just
single paged invoices. Now I need to generate multi-paged invoices. My
(SQLWindows) code loops through all invoice items, and inserts the pre-
formatted text for an invoice item before the autotext field
"invoice_item". Thus this acts more like a marker than an actual
autotext field. I guess using this aproach I have no other choice than
to also insert lines for footer page total, page break and page header
total.

Maybe I should have asked if there is any better aproach, so that the
logic for calculating and including those page totals in the layout is
done by Word. I know that you can define "fields" (don't know the
exact expression as I'm using a german version of Word) and let word
calculate values. But this only works with a fixed set of predefined
fields. I don't know in advance how many invoice Items an invoice has.
Also I can't remember a Word feature to layout those page totals. But
with the huge set of finctionality in Word you never know if you
didn't overlooked something...

One idea would be to define an autotext field "running_total" and
calculate the value in SQLWindows and pass it to Word before a new
invoice item is sent. Again, the value must be inserted as text before
the autotext field (because ONE autotext field can't have different
values on different locations in the document).

Stefan
 
S

StefanM

I have been playing a bit with Word's functionality and created a
sample document using a table and SUM(ABOVE) to calculate a
"PageTotal", that gets summed up to a "DocTotal".

The problem is, that I cannot use the calculated values by those SET
statements in the page footer/header as only on the footer on the
first page and on the header of the secobd page the correct values get
displayed. An all following footers/headers, these values get
repeated. So ot seems that the contents of the footer/header is
"static" regarding these values and not "dynamic".

So bottom line is: I can't really use these features because they
don't work the way I expected them to work. Up to now my solution
would be to "inject" a line with the running total, a page break and
repeat the running total on top of the next page before sending the
next invoice item line.

Even when using a table and SUM(ABOVE) I would have to inject these
"sum" lines and page breaks in my table.

Is there any other solution I'm currently not aware off?

Thanks,
Stefan
 
J

Jay Freedman

Hi Stefan,

The characteristic of headers and footers is that there is only one (of each
of the three types Primary, Even Page, and First Page) for each section.
Further, if there are multiple sections, each type of header or footer in
each section has a "Link To Previous" attribute that can make it repeat the
content of the corresponding header/footer of the preceding section.

The only way you'll be able to get this scheme to work is to make each page
a separate section (by inserting section breaks at the proper places), and
turning off all the "Link To Previous" attributes. Only then can each page
have a different text in the header or footer.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 

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