Results 1 to 6 of 6
  1. #1
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Macro to determine odd/even page no (Word 2002 SP2)

    I was wondering if there is a way to find out if the last page of the document is odd or even number? If odd, add a blank page at the end of the document.

    Thanks.

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Macro to determine odd/even page no (Word 2002 SP2)

    <P ID="edit" class=small>(Edited by jscher2000 on 12-Aug-03 14:23. Maybe this helps a bit more....)</P>Assuming you have the document open... you could create a macro that goes to the end of the document, checks the page number and, if needed, inserts a page break to generate the blank page. As you know, there are both physical and logical page numbers, and the latter may not match if the document has been divided into sections or the first page in the document is numbered something other than 1. How would you want the macro to behave in this case - go by the logical page number?

    Added: The properties of interest are:

    intPgPhsyical = Selection.Information(wdActiveEndPageNumber)
    intPgLogical = Selection.Information(wdActiveEndAdjustedPageNumbe r)

    You also can use a Range object rather than the Selection if you prefer, but it's generally easier to use Selection. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

  3. #3
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to determine odd/even page no (Word 2002 SP2)

    Hi Jscher:

    I apologize, I did not make the first message clear enough. I am able to get the page number, what I don't know how to do is to check if it's odd or even number, LOL.

    I used to be able to search the archives to find help. Is that not available anymore?

    Thanks.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Macro to determine odd/even page no (Word 2002 SP2)

    1. Searching has been disabled for over three months now, because the server threatened to succumb under the burden searching imposes. See <!post=Temporary suspension of Search facility,250092>Temporary suspension of Search facility<!/post>.

    2. If you have the number of pages in a variable intPageNum, you can determine whether it is odd or even by using Mod: intPageNum Mod 2 returns 0 is intPageNum is even, and it returns 1 if it is odd. (Mod 2 means calculate the remainder after division by 2 - even numbers are cleanly divisible by 2, so the remainder is 0, while odd numbers leave 1)

  5. #5
    2 Star Lounger
    Join Date
    May 2001
    Location
    Columbia MD USA
    Posts
    107
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Re: Macro to determine odd/even page no (Word 2002 SP2)

    The Word MVP FAQ site has an article you might find useful if you want to accomplish this without macros. It can be found at: http://www.mvps.org/word/FAQs/TblsFldsFms/...vnPgEndChap.htm .

    I find that I need to force word to repaginate more often when I use this at the end of chapters/sections, however, its still pretty useful.

  6. #6
    2 Star Lounger
    Join Date
    Aug 2001
    Posts
    158
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Macro to determine odd/even page no (Word 2002 SP2)

    Thanks! Works great!.

Posting Permissions

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