Results 1 to 12 of 12
  1. #1
    New Lounger
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    5
    Thanked 1 Time in 1 Post

    Angry Page Numbering with Continuous Section Breaks

    I've spent the better part of the last 4 hours attempting to solve this issue. I found a work around (a macro), but I'm posting this in hopes that one of the Word gurus here can offer me a nonmacro-related solution, as ideally I'd like to save the document without it having to be "macro enabled".

    I'm working on a technical manual that is required to be in a two-column format. As such, there are a significant number of continuous section breaks throughout the document - all of the chapter/section headings are formatted for one column to allow them to be centered on the page; also in the event that a figure or table needs to be wider than 3 inches, it will also be contained in a one column section.

    The manual is also required to have odd/even pages so that the header/page number (which is in the footer) jumps from right to left as each page changes.

    I consider myself to be a fairly advanced user of Word (though I don't really get much into macros/VBA), and can usually troubleshoot most formatting issues that arise. Keep that in mind as I (finally) get to presenting my problem. I am very well versed in how to use the page number formatting and I know the issues that our good friend "Link to Previous" can present, so answers that suggest doing either of those things are unnecessary - trust me, I've tried EVERYTHING.

    Ok, now the problem - the page numbers WILL NOT stay continuous throughout an entire chapter. The ToC starts at page i; pages ii and iii were fine, but what should be page iv is showing ii (and all of the subsequent pages in the rest of the section read ii as well). Also, at the same point the page numbers quit playing nice, the document recognizes each subsequent page and an "Odd Page" (which may be a whole separate issue, i know). Each chapter ends with a Next Page section break, and in the following chapter the page numbering cooperates until it gets to about the fifth page, then it all goes wonky again.

    Now, at first I started just forcing the page numbers to be the correct number - by going to each footer and setting the Start at: page to be the correct number. That worked ok for the chapters that had only a few pages. Unfortunately, one of the chapter is about 100 pages long, so that's the point I realized my solution wasn't going to fly for long and hit Google looking for a solution.

    I found the following macro (from Stefan Blom) on a Microsoft Community page:

    Sub SetContinuousPageNumbering()
    Dim s As Section
    For Each s In ActiveDocument.Sections
    s.Headers(wdHeaderFooterPrimary) _
    .PageNumbers.RestartNumberingAtSection = False
    Next s
    End Sub

    The macro worked perfectly, and all I had to do was go back into the beginning of each chapter and reset the Start at: page to 1 (my page numbers include the chapter number if that makes any difference).

    Like I said, i would ideally like to save this document without it having to be "macro enabled", so I'd love to find another solution if one exists.

    Unfortunately (because I'm sure the question would come up), I cannot post the document here due to export control issues.

    Any help/suggestions are welcome and appreciated. Sorry for the novel.

  2. #2
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by RoobyDooby View Post
    The manual is also required to have odd/even pages so that the header/page number (which is in the footer) jumps from right to left as each page changes.
    You don't need an odd/even pages layout for this; just a bit of field coding and an ordinary page layout and a left-aligned footer with a right-aligned tab-stop at the right margin. For the field coding, one on the left and one on the right, use:
    {IF{=MOD({PAGE},2)}= 1 {PAGE}} - odd numbers
    {IF{=MOD({PAGE},2)}= 0 {PAGE}} - even numbers

    Note: The field brace pairs (i.e. '{ }') for the above examples 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.

    As for the macro, try:
    Code:
    Sub SetContinuousPageNumbering()
    Application.ScreenUpdating = False
    Dim i As Long
    With ActiveDocument
      For i = 2 To .Sections.Count
        With .Sections(i)
          With .Headers(wdHeaderFooterPrimary)
            .LinkToPrevious = True
            .PageNumbers.RestartNumberingAtSection = Not _
              (.Range.PageSetup.SectionStart = wdSectionContinuous)
          End With
        End With
      Next
    End With
    Application.ScreenUpdating = True
    End Sub
    This should obviate the need to
    go back into the beginning of each chapter and reset the Start at: page to 1
    Note that the macro assumes you don't use the odd/even page layout.

    Running a macro in a document doesn't mean you have to save it as a macro-enabled one; if you save it as not macro-enabled, the macro will be discarded but that should be OK once it's done its work. As an alternative, you could store the macro in your document's template (probably Normal.dotm) and have it available at any time.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  3. The Following User Says Thank You to macropod For This Useful Post:

    RoobyDooby (2016-09-22)

  4. #3
    New Lounger
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    5
    Thanked 1 Time in 1 Post
    Thank you Paul! As I have two more manuals of this same type to complete, I'll try your macro on the next one instead of using the odd/even pages.

    Some clarification on the field codes: I will place both codes in the footer? Also, do I need to do something similar in the header (which contains the document number)?

  5. #4
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    You can use this Add-In which has a similar macro on the Ribbon. So long as the Add-In is loaded, you can run the macro in any open document.
    The document will not need to be macro enabled.
    2010HeaderFooterContinuousPageNumbers.png


    BTW: Chapter numbering is an anachronysm that can cause problems, sometimes big problems.
    Last edited by Charles Kenyon; 2016-09-22 at 15:26.
    Charles Kyle Kenyon
    Madison, Wisconsin

  6. #5
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Quote Originally Posted by RoobyDooby View Post
    Thank you Paul! As I have two more manuals of this same type to complete, I'll try your macro on the next one instead of using the odd/even pages.

    Some clarification on the field codes: I will place both codes in the footer? Also, do I need to do something similar in the header (which contains the document number)?
    Yes, you put both codes in. One displays on even-numbered pages, and one on odd-numbered pages. If you want the position of the document number in your header, yes you want to use the fields there as well.
    Charles Kyle Kenyon
    Madison, Wisconsin

  7. The Following User Says Thank You to Charles Kenyon For This Useful Post:

    RoobyDooby (2016-09-22)

  8. #6
    New Lounger
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    5
    Thanked 1 Time in 1 Post
    Thank you Charles. I've been successful in inserting the codes for the page numbers in the footer.

    Unfortunately, I've not been so successful with the doc number in the header. If my doc number is TM12345678, how do I update the code to display that text?


    UPDATE: After a short Google session, I figured it out

    Thank you both again for your assistance!
    Last edited by RoobyDooby; 2016-09-22 at 16:32.

  9. #7
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by RoobyDooby View Post
    Some clarification on the field codes: I will place both codes in the footer? Also, do I need to do something similar in the header (which contains the document number)?
    Yes, both field codes go in the same footer, separated by a tab character. Unless you have different odd/even headers, nothing need be done there.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #8
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by Charles Kenyon View Post
    You can use this Add-In which has a similar macro on the Ribbon. So long as the Add-In is loaded, you can run the macro in any open document.
    Yes, but it doesn't do the same thing as my macro, which re-starts the page numbering after anything other than a 'Continuous' Section break (e.g. a 'Next Page' Section break), which is the numbering scheme the OP is using.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  11. #9
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    No, you are correct,; it is more of a blunt force approach. It makes numbering continuous and lets the user sort it out. While I think this is what most people need, your macro addresses the needs of the user better. I've put an annotation to this thread in my Add-In in case someone wants something more.
    Last edited by Charles Kenyon; 2016-09-23 at 15:34.
    Charles Kyle Kenyon
    Madison, Wisconsin

  12. #10
    New Lounger
    Join Date
    Feb 2014
    Posts
    7
    Thanks
    5
    Thanked 1 Time in 1 Post
    Quote Originally Posted by macropod View Post
    Unless you have different odd/even headers, nothing need be done there.
    I do need the document number in the header to only display on the same side (left or right) as the page number. I thought I had figured it out last week, but apparently I did a data dump over the weekend and can't seem to get it working today...

  13. #11
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts
    Again, use the field codes that Paul gave you. Both in every header.
    Charles Kyle Kenyon
    Madison, Wisconsin

  14. #12
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Quote Originally Posted by RoobyDooby View Post
    I do need the document number in the header to only display on the same side (left or right) as the page number. I thought I had figured it out last week, but apparently I did a data dump over the weekend and can't seem to get it working today...
    In that case, you can still use using an ordinary page layout and a left-aligned header with a right-aligned tab-stop at the right margin. For the field coding, one on the left and one on the right, use:
    {IF{=MOD({PAGE},2)}= 1 "####"} - odd pages
    {IF{=MOD({PAGE},2)}= 0 "####"} - even pages
    where '####' is the document number. If that number is stored in a document property or variable, for example, you can use a DOCPROPERTY/DOCVARIABLE field instead of the "####".
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  15. The Following User Says Thank You to macropod For This Useful Post:

    RoobyDooby (2016-10-03)

Posting Permissions

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