TITLE: Placing Page N of N in a Header or Footer PRODUCT: WordPerfect 5.1 for DOS Problem You want to put page numbers in a header or footer, and you want it to read Page n of n, where the first n is the current page and the second n is the total number of pages in your document. Concept You can create a macro to place your page number in a header or a footer. Using the Cross Reference feature to mark text, you can write the macro to insert the proper page numbers as indicated. Your footer will display consecutive page numbers as Page 1 of 3, Page 2 of 3, and so on. Solution Create a macro that inserts Page n of n in a footer. Note: Do not use this macro if the document already contains a Footer B. If you do use this macro and you have already created a Footer B at the beginning of your document, it will be overwritten. If you have created a Footer B later in your document, it will overwrite this macro. You can change this macro to print in the header, as indicated after step 5. 1 Press Macro Define (Ctrl+F10). 2 Type pagen at the Define macro prompt. 3 At the Description prompt, type Inserts Page n of n in a footer. You are now in the Macro Define mode. Every keystroke that you make will be recorded in your macro. 4 Press Home, Home, Up Arrow. 5 Press Format (Shift+F8), then choose Page (2), and Footers (4). If you want to place the page number within a header, select Headers (3) instead of Footers (4). 6 Choose Footer B (2), then Every Page (2). 7 Press Flush Right (Alt+F6), type Page, press the Space Bar, then type ^B (Ctrl+B). 8 Press the Space Bar, type of, then press the Space Bar again. 9 Press Mark Text (Alt+F5), then choose Cross-Ref (1) to insert the total number of pages. 10 Choose Mark Reference (1), then Page Number (1). Type end at the Target Name prompt and press Enter. A question mark (?) will be inserted at this point in the footer. It will be replaced by the page number when the document is generated. 11 Press Exit (F7) twice to return to the document screen. 12 Press Home, Home, Down Arrow so the macro will go to the bottom of the document, then press Mark Text (Alt+F5). 13 Choose Cross-Ref (1), then Mark Target (2). The target name you entered earlier will appear. Press Enter to accept it. 14 Press Mark Text (Alt+F5), then choose Generate (6) and Generate Tables, Indexes, Cross-References, etc. (5). Press Y to answer Yes to continue. 15 Press Macro Define (Ctrl+F10) to stop recording the macro. Your finished macro should look like this: {DISPLAY OFF}{Home}{Home}{Up}{Format}2422{Flush Right}Pageù{^B}ùofù {Mark Text}111end{Enter} {Exit}{Exit}{Home}{Home}{Down}{Mark Text}12{Enter} {Mark Text}65y When you are ready to run the macro, you will first need to have a document on your screen. To run the macro, 1 Press Macro (Alt+F10). 2 Type pagen and press Enter. You can preview the document to see how your footer will look when it is printed. 1 Press Print (Shift+F7), and choose View Document (6). 2 Press Exit (F7) to return to the document editing screen. If text is added to or deleted from your document, you will need to delete the [Footer B...] code from the beginning of your document and the [Target(END)] code from the end of your document. You will then need to run the macro again so the page numbers will be updated. To easily find the [Target(END)] code, 1 Press Search (F2), then press Mark Text (Alt+F5). 2 Choose Defs and Refs (5) and Target (4). 3 Press Search (F2). The cursor will move to the Target code. 4 Press Backspace to delete the code (press Y to answer Yes, if necessary). See Also  Macros, Macro Editor in the WordPerfect 5.1 for DOS reference manual  Generate in the WordPerfect 5.1 for DOS reference manual  Cross Reference in the WordPerfect 5.1 for DOS reference manual  Headers and Footers in the WordPerfect 5.1 for DOS reference manual