Conditionally show page numbers

Long documents with multiple pages usually have page numbers. Numbering pages help the reader go through the document in the right order the writer intended. Many word processing applications have automatic page numbering feature, which increases and adjusts the numbers while writing the document. Microsoft Word, among others, has special PAGE field that shows the current page number when inserted anywhere in the document page. When the page count increases the number field is automatically updated. To ensure the reader has all the pages the document also has the total number of pages printed next to the running number. The total count can be seen in brackets, for example: 1 (8). Word has NUMPAGES field to show the total number of pages.

I wanted to add the automatic page numbering as well as the total number of pages in my documents. I also wanted to show the numbers only when the document has more than one page. This required conditional page numbering, which was relatively easy to implement with Word. Here are the steps to do the trick:

  1. Place the cursor where you want the page number to appear.
  2. Press Control + F9 keys simultaneously. A gray box with curly brackets appears.{ }
  3. Write word IF inside the curly brackets.{ IF }
  4. Press Control + F9 keys again and another set of curly brackets appear.{ IF {} }
  5. Write word NUMPAGES inside the curly brackets.{ IF { NUMPAGES } }
  6. Move the cursor between two last brackets and write greater than character and number one and two quotation marks.{ IF { NUMPAGES } > 1 "" }
  7. Move the cursor between two quotation marks and press Control + F9 keys.{ IF { NUMPAGES } > 1 "{ }" }
  8. Enter word PAGE inside the curly brackets.{ IF { NUMPAGES } > 1 "{ PAGE }" }
  9. Move the cursor outside the curly bracket and enter brackets to surround the total page count.{ IF { NUMPAGES } > 1 "{ PAGE } ()" }
  10. Move the cursor between two brackets and press Control + F9 keys.{ IF { NUMPAGES } > 1 "{ PAGE } ({ })" }
  11. Write word NUMPAGES inside the curly brackets.{ IF { NUMPAGES } > 1 "{ PAGE } ({ NUMPAGES })" }

This conditional page numbering first tests whether the document has more than one page. In case there are multiple pages, the expression then displays the current page number and the total number of pages in brackets. Press Alt + F9 keys twice to see how the testing expression works. If you need to modify the test, just press Alt + F9 keys again and make any changes. Remember to enter space character to separate curly brackets and test operation character from each other. Consult the Word help for more information on how to use the IF expression and field codes.

Julkaistu perjantaina 7.1.2011 klo 18:12 avainsanoilla ohjelmistot ja ohjelmointi.

Edellinen
Loppiainen
Seuraava
Mittasuhteet