+ Reply to Thread
Results 1 to 25 of 25

Fixed last page header/footer without the use of section breaks

  1. #1
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Fixed last page header/footer without the use of section breaks

    In a word template, is there a way to make certain information to always appear only on the last page in the header and footer without the use of section breaks? The problem with the section break is that I wish the text to automatically continue to the last page as well (so that the last page will have text + unique header and footer). Also, in my document the front page header and footer should be different. I am thankful for any help!

  2. #2
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    If you configure the document with a 'different first page' layout, you can have a header & footer that only appears on the first page. For the remainder of the document, you can use field coding to test whether the page is the last page. For example, you might use a field coded like:
    {IF{PAGE}={NUMPAGES} "Content for last page"}
    To insert such a field in a document using a 'different first page' layout, you would need to at least temporarily create a second page so you can access its header/footer.

    Note: The field brace pairs (i.e. '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practical to add them via any of the standard Word dialogues. The spaces represented in the field construction are all required.
    Cheers,
    Paul Edstein
    [Fmr MS MVP - Word]

  3. #3
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Cross-posted and answered at: http://www.msofficeforums.com/word-v...thout-use.html
    Also cross-posted at: http://www.vbaexpress.com/forum/show...section-breaks
    Please read Excel Forum's Cross-Posting policy in rule #8: http://www.excelforum.com/forum-rule...rum-rules.html

  4. #4
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Many thanks for the helpful advice! Do you know what kind of code is required to access the last page header and footer? Where is the code to be pasted? I tried recording a macro that would add the header and footer but I did not succeed. I am completely new to VBA so any help is highly appreciated! Thanks again!

  5. #5
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Quote Originally Posted by HelpNeed View Post
    Do you know what kind of code is required to access the last page header and footer?
    There is no such thing as a 'last page' header or footer. The field code (not a macro) I suggested can go in any header or footer - be that a 'first page', 'odd page' or default header or footer. All you need do is ensure you have it in the appropriate one(s) for your document's page layout.

  6. #6
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thank you for your reply! What is the general code to access any header/footer? What is it that I should do with the field code? I tried adding it to Modules but I couldn't make it to work. Sorry for my elementary questions!

  7. #7
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Quote Originally Posted by HelpNeed View Post
    What is the general code to access any header/footer?
    If you're referring to VBA, that depends on the header/footer you want to access. Every Section in a document has three header objects and three footer objects.
    Quote Originally Posted by HelpNeed View Post
    What is it that I should do with the field code?
    You would follow the instructions given in post #2.
    Quote Originally Posted by HelpNeed View Post
    I tried adding it to Modules but I couldn't make it to work.
    Hardly surprising, since it's field coding, not VBA.

  8. #8
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thank you so much for help! I got it to work now but the problem is that everytime I open the document and start writing the computer screen starts blinking and eventually Word crashes. Do you have an idea what could be the reason for this? Maybe my computer/Word is not powerful enough to add quite a big and complex footer (with a picture) in field coding?

  9. #9
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Have you tried repairing the Office installation (via Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change > Repair)?

    Are you sure the document hasn't acquired some form of corruption? Corrupt documents can often be 'repaired' by inserting a new, empty, paragraph at the very end, copying everything except that new paragraph to a new document based on the same template (headers & footers may need to be copied separately), closing the old document and saving the new one over it.

  10. #10
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Many thanks for the advice! I tried with a new document to check if the file could be corrupted but the problem persists. Both the header and footer work fine with a simple line of text but when I have a longer footer with formatting (or a picture) Word starts to blink and becomes very slow. It seems like the program gets confused when it needs to check all the time if it is the final page, and sometimes it even puts the footer both on the second last and the last page for a moment. Is this a known weakness of Word? The footer is not advanced in any way, just a few rows of text with formatting. What could be the reason? Thank you for your help!

  11. #11
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Without actually seeing the problem document, it can be difficult to diagnose the issue. Can you attach a document to a post with some representative data (delete anything sensitive)? You do this via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.

  12. #12
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thanks, that's a good idea. Here is an example file with some representative data. If you start writing on the document (I pasted in bits of text) at some point it takes longer and longer for Word to think, Word becomes slow and eventually the screen freezes. Thank you for any help!
    Attached Files Attached Files

  13. #13
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    I took your sample document, added 112 pages of random text and found no performance anomalies. Perhaps there's some other issue with your office installation and/or your display driver and/or printer driver.

    You might try repairing the Office installation (via Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change > Repair) and updating your display & printer drivers.

  14. #14
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Wow that is really interesting! Thank you! Since the header is working fine I decided to only stick to it and leave out the footer. Do you know if there is a similar way to use field coding to say to Word not to add a page number and date on the last page footer? Any help is appreciated!

  15. #15
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    {IF{PAGE}={NUMPAGES} "Content for last page" "Content for other pages"}
    or:
    {IF{PAGE}<{NUMPAGES} "Content for other pages"}

  16. #16
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thank you! Do you know if there is a way to make Word to read all the field codes only at the end of the session, for example just before printing? I think this could help my crash problem since Word would not be constantly calculating what the last page is.

  17. #17
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Possibly by working in draft view and switching off background repagination. Did you do the other remedial action I suggested?

  18. #18
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thank you for the advice! Yes I did but it did not help unfortunately... I wonder if, in theory, it would be possible to code a macro to add the last page header/footer without the use of section breaks? I assume this kind of macro cannot be recorded but would need to be written. Or is field coding the only way to go?

  19. #19
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    A macro would have to apply the same field coding that you've already been given...

  20. #20
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    I see! But with a macro, the Word would not need to be "thinking" all the time whether this is the last page (which I assume causes Word to become slow), but it could be added at the very end of the writing process with the help of a button, right? Do you know how complicated this kind of macro would be to write?

  21. #21
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    As I said previously:
    Quote Originally Posted by macropod View Post
    I took your sample document, added 112 pages of random text and found no performance anomalies.
    so it's not apparent to me that you're addressing the underlying issue.

    Sure, a macro could be written but, without knowing exactly what's required, that would be a chore. You could just as easily - more easily, in fact - simply store the required field code in another document and paste it into the one you're working with when you've finished the editing.

  22. #22
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    Thank you for your help! I tried the remedies but for some reason in my computer the field code in the footer causes Word to become slow and makes the cursor to start blinking. Having another document to work with was actually in my mind but because the formatting is quite complicated (with many images) copy-pasting will cause the text to lose some of its structure unfortunately. What do you mean by knowing exactly what's required for the macro? Do you mean that the exact fonts and formatting of the header and footer will be included in the code?

  23. #23
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    All that needs to be in the 'other' document is the field code and its contents; I'd have thought that quite plain from post #21. I said nothing of putting any other content there.

    A macro to create the field code and its contents would have to be coded with all the relevant details, including: font details (including every change it font name, point size, italcs, bold, etc.); paragraph formatting; table layouts (if used); image locations on disc and their formatting in the field code; etc.

  24. #24
    Registered User
    Join Date
    06-27-2017
    Location
    Stockholm, Sweden
    MS-Off Ver
    2003
    Posts
    12

    Re: Fixed last page header/footer without the use of section breaks

    I see! But in that case, as you mentioned earlier, the macro would apply the same field code as previously so I am not sure if that would help much. How difficult is this kind of code to write? I am thinking especially the footer since it includes text in 3 different columns. Thank you!

  25. #25
    Forum Expert macropod's Avatar
    Join Date
    12-22-2011
    Location
    Canberra, Australia
    MS-Off Ver
    Word, Excel & Powerpoint 2003 & 2010
    Posts
    3,726

    Re: Fixed last page header/footer without the use of section breaks

    Well, since it would apply the same field code you already have and you don't think that's going to help much (which accords with my previous advice), I don't see why you'd bother.

    The macro code to add a fairly simple conditional field, coded as:
    { IF{ PAGE }={ NUMPAGES } { FILENAME } }
    which displays the document name only on the last page's footer, without any regard to formatting, would be:
    Please Login or Register  to view this content.
    once you get into formatting, with multiple columns etc., things get a whole lot more complicated. Conditional field coding via VBA is far from intuitive...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 5
    Last Post: 03-19-2012, 06:14 PM
  2. Excel 2007 : Custom Header and Page Breaks
    By jray9242 in forum Excel General
    Replies: 0
    Last Post: 06-14-2011, 12:12 PM
  3. Controlling Page/Section Breaks
    By HighlandScott in forum Word Formatting & General
    Replies: 1
    Last Post: 02-06-2009, 07:49 AM
  4. Replies: 1
    Last Post: 07-24-2006, 05:29 AM
  5. [SOLVED] excel -10 sections - footer needs to say "Section # Page #
    By Maggie in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 05-09-2006, 10:10 PM
  6. Replies: 3
    Last Post: 10-07-2005, 02:05 PM
  7. Macro page breaks on column value not row 1 - use value in footer?
    By misscrf in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-06-2005, 02:18 PM
  8. [SOLVED] Using an input box to enter information into the header section of page setup
    By George Taylor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2005, 02:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1