Results 1 to 10 of 10
  1. #1
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I am following Suzanne S. Barnhill's excellent little paper "How to set up a document with front matter numbered separately" and enjoying it immensely; so much so that I have embarked on yet another generic page header/footer macro that copes with multiple sections.

    Recording a macro to follow Suzanne's steps finds me with a WdPageNumberStyle type constant as a result of using the "Format Page Number button".
    So far so good:
    Code:
        With Selection.HeaderFooter.PageNumbers
            .NumberStyle = lngNumberStyle ' e.g. wdPageNumberStyleLowercaseRoman
            .RestartNumberingAtSection = blnRestartNumberingAtSection
            .StartingNumber = 1
        End With
    Now I decide to insert an extra field in the footer, a SECTIONPAGES field (as in "Page 2 of 7 pages in this section")
    Recording THAT action yields this:
    Code:
        Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= "SECTIONPAGES \* roman", PreserveFormatting:=True
    While the Headers/Footers toolbar allows me to insert a page number (and restart at unity in a section) it does not allow me to insert a number-of-pages-in-this-section.
    For that I have to insert a field.
    The field requires a text switch "\* roman", whereas the header/footer toolbar page number takes a long switch wdPageNumberStyleLowercaseRoman.

    There is obviously a 1-1 correspondence between the text and long versions of the switch, but I can't find any such mapping within Word2000/VBA.

    My current thoughts are abandon the use of the header/footer toolbar facility for the page number, and rely on insertion of the two fields (PAGE and SECTIONPAGES) employing a common text switch to preserve the sanity of whoever uses the generic function

    As usual, I throw myself at the feet of my intellectual superiors and beg for comments ....

    (minutes later)
    Investigation of inserting the field PAGE shows that choosing the Default formatting options appears to make the field inherit the formatting applied to the section.
    Code:
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="PAGE ", PreserveFormatting:=True
    That is, the handy LONG constant, once used to indicate the formatting for the section can be re-employed by default in the PAGE and other fields).

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Setting PageNumbers.NumberStyle will only affect PAGE fields in the header or footer, not NUMPAGES or SECTIONPAGES fields. You have to use a \* switch to change the numbering style for the latter.

    In my version of Word (2002), the number of options available for NumberStyle is much larger than the number of options for the \* switch: it includes options for several Middle Eastern and Far Eastern languages.

  3. #3
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    not NUMPAGES or SECTIONPAGES fields.
    ... as I have discovered!
    ... includes options for several Middle Eastern and Far Eastern languages.
    Yes, and Word2000 has a great many more listed in the constants for types than are shown in the text strings for Options in the Field switches.

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Chris,

    The following field code, placed in the header or footer of a document, creates X of Y page numbers for individual Sections, independently of any other page numbering in the document.
    {QUOTE{IF{PAGE}= 1 {SET Section0 0}}
    {IF{PAGE}<>{NUMPAGES} {IF{={SECTIONPAGES}+{REF {QUOTE Section{={SECTION}-1}}}}={PAGE} {SET {QUOTE Section{SECTION}} {PAGE}}}}
    "Page {={PAGE}-{REF {QUOTE Section{={SECTION}-1}}}} of {SECTIONPAGES}"}

    How this works:
    The field creates a series of bookmarks named Section# (where # is the Section number) and assigns the corresponding Section's SECTIONPAGES count to them.
    The code then deducts the previous Section's page count from the current page number to determine the current Section page# for the X of Y numbering for the Section.
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    The following field code,
    {{Nice One, {{Macropod}}}. {Did we ever write a {text-to-field {converter}}}? {{I ran this lot {through my {nested parser}}}, and {it came up {smiling}}}. {I could add a "{write field code}" to it {if {that }makes sense}}.}

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by chrisgreaves View Post
    {Did we ever write a {text-to-field {converter}}}?
    Jefferson Scher did - see the attachment to Page Numbering (2000).

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by HansV View Post
    Jefferson Scher did
    Thanks Hans.
    I thought I had seen one, but my search came up empty.
    Bit of a bad start to the week having something made-to-order on hand; I was hoping to write one during my lunch-break.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Quote Originally Posted by chrisgreaves View Post
    Thanks Hans.
    I thought I had seen one, but my search came up empty.
    It was a Star Post in a previous incarnation of the Lounge, it's still listed in StarPost Index - Office Applications.

  9. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,055
    Thanks
    2
    Thanked 417 Times in 346 Posts
    Hi Chris,

    Perhapsyou need something along the lines of:
    {QUOTE 109 97 99 114 111 112 111 100 32 119 97 115 32 104 101 114 101 33}
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #10
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by macropod View Post
    {QUOTE 109 97 99 114 111 112 111 100 32 119 97 115 32 104 101 114 101 33}
    macropod is EVERYwhere!

Posting Permissions

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