Creating footer for last page of document 
Author Message
 Creating footer for last page of document

Hi, Greg,

Put a field like this in the regular footer:

{ IF { PAGE } = { NUMPAGES } "Your data here"  "" }

where each pair of braces is created by pressing Ctrl+F9. This will compare the
current page number to the total number of pages in the document. If they're
equal (that is, this is the last page), the field result will be the string
inside the first pair of quotes. On any other page, the field result is nothing.

After putting the field into the footer, put the cursor anywhere in the field
and press F9 to update it.

--
Regards,
Jay Freedman
Microsoft Word MVP        Word MVP FAQ site: http://www.*-*-*.com/

Quote:

> I have a word 2000 document that I programmatically create
> from vb6.  I want
> to put some data in a footer in the last page of the
> document.  The document could range
> from 1 - 3 pages.  I tried after outputting all my text in
> the main body
> adding a section and then pasting the data into the footer
> for that section;
> however, it still puts the data in all pages of the
> document.  Any ideas
> or sample code would be greatly appreciated.



Tue, 24 May 2005 11:53:19 GMT  
 Creating footer for last page of document
Jay,

Thanks for the reply and the tip.  How do I do what you've
suggested programmatically?  I have a vb6 application that
is creating this document through automation and the
footer needs to be done through automation.  Thanks for
any assitance/guidance.

Quote:
>-----Original Message-----
>Hi, Greg,

>Put a field like this in the regular footer:

>{ IF { PAGE } = { NUMPAGES } "Your data here"  "" }

>where each pair of braces is created by pressing Ctrl+F9.

This will compare the
Quote:
>current page number to the total number of pages in the

document. If they're
Quote:
>equal (that is, this is the last page), the field result
will be the string
>inside the first pair of quotes. On any other page, the

field result is nothing.
Quote:

>After putting the field into the footer, put the cursor

anywhere in the field
Quote:
>and press F9 to update it.

>--
>Regards,
>Jay Freedman
>Microsoft Word MVP        Word MVP FAQ site:

http://www.mvps.org/word
Quote:


>> I have a word 2000 document that I programmatically
create
>> from vb6.  I want
>> to put some data in a footer in the last page of the
>> document.  The document could range
>> from 1 - 3 pages.  I tried after outputting all my text
in
>> the main body
>> adding a section and then pasting the data into the
footer
>> for that section;
>> however, it still puts the data in all pages of the
>> document.  Any ideas
>> or sample code would be greatly appreciated.

>.



Wed, 25 May 2005 01:44:27 GMT  
 Creating footer for last page of document
Hi, Greg,

See the suggestions and code in
http://www.mvps.org/word/FAQs/MacrosVBA/NestedFieldsWithVBA.htm. Especially note
the statement 'Using selections in Headers or Footers is a complete no-no. So if
you need to create a nested Headers or Footer field on the fly, create the
field in the main document, and cut and paste it into the Headers or Footer' and
the last macro in the article.

If you make a reference to the Word object model in the VB project, you should
be able to use the VBA pretty much intact, except for changing the inserted bits
to form the field I indicated, and pasting into .Footers(wdHeaderFooterPrimary
instead of .Headers(wdHeaderFooterPrimary.

--
Regards,
Jay Freedman
Microsoft Word MVP        Word MVP FAQ site: http://www.mvps.org/word

Quote:

> Jay,

> Thanks for the reply and the tip.  How do I do what you've
> suggested programmatically?  I have a vb6 application that
> is creating this document through automation and the
> footer needs to be done through automation.  Thanks for
> any assitance/guidance.
>> -----Original Message-----
>> Hi, Greg,

>> Put a field like this in the regular footer:

>> { IF { PAGE } = { NUMPAGES } "Your data here"  "" }

>> where each pair of braces is created by pressing Ctrl+F9. This will
>> compare the current page number to the total number of pages in the
>> document. If they're equal (that is, this is the last page), the
>> field result will be the string inside the first pair of quotes. On
>> any other page, the field result is nothing.

>> After putting the field into the footer, put the cursor anywhere in
>> the field and press F9 to update it.

>> --
>> Regards,
>> Jay Freedman
>> Microsoft Word MVP        Word MVP FAQ site: http://www.mvps.org/word


>>> I have a word 2000 document that I programmatically create
>>> from vb6.  I want
>>> to put some data in a footer in the last page of the
>>> document.  The document could range
>>> from 1 - 3 pages.  I tried after outputting all my text in
>>> the main body
>>> adding a section and then pasting the data into the footer
>>> for that section;
>>> however, it still puts the data in all pages of the
>>> document.  Any ideas
>>> or sample code would be greatly appreciated.

>> .



Wed, 25 May 2005 12:28:16 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Footer on last page of document

2. Print report page footer last page only?

3. suppress page footer section in the last page

4. Create a Page Footer in a Word Document

5. Footer on all pages except the last one

6. Template Problem - footer that appears at end of last page

7. Template Problem - footer that appears at end of last page

8. How to suppress footer until last page

9. Header/footer last page

10. Section break on last page of document

11. removing last page of a document

12. Delete the last page in a document?

 

 
Powered by phpBB® Forum Software