Page Number macro for Word 2010 and Personal Book Files

Dominick Sela
Dominick Sela Member Posts: 3,641 ✭✭✭

Attached find a macro file I wrote for adding a Personal Book field, of form [[Page:XX]], at the top of each page of your Personal Book file!  Please feel free to try it out, it's in the attached zip file.

Note: If you have not enabled Macros in Word 2010, you can Google how to do it or check this site out.

Once macros are enabled on your copy of Word 2010, here are the Instructions on trying this out:

1. Take File and Save it to your Word Startup folder. On my PC it is:
C:\Users\<UserName>\AppData\Roaming\Microsoft\Word\STARTUP
(You can verify the location in Word 2010 by checking File/Options/Advanced/File Locations (button), then see what path it says for "Startup"

2. Run Word 2010. Go to View, click on the Macros button, You should see two Macros, "ClearPageFields" and "NextPage". If you want to see the code I wrote, click the macro name and then click Edit.  But the important thing is, if you see those two names, you have the macros installed into Word!

The two macros are these: 

ClearPageFields: will clear out ALL page fields in your file.

NextPage: Clears any PageField notations, then adds a new page field in the form [[Page:XX]] at the beginning of each page.

3. Close the Macro dialog box for now, and Open up your source PB file (File/Open).

4. Run the macros!


Important Notes:

1. These macros rely on the background re-pagination of the document as the page number fields are inserted (ie, depending on the size of your document, the number of pages grows).  I suspect that depending on your document there may be times when the background re-pagination does not finish, and the [Page:XX]] gets put in the wrong place. Let me know if you see this, my computers are too fast to detect this [;)].

2. If you run one of these macros and want to revert your document back to a state prior to running the macro, or (heaven forbid!) the macro does something messy, just hit Ctrl-Z to Undo and revert back!

3. Tested on Windows 7 and Word 2010 only. I don't think I use anything that won't work in Word 2007, maybe 2003? Let me know but no guarantees.

4. Use at your own risk!

5. If you see a problem or want to request an enhancement, PLEASE post a Personal Book source document if appropriate that shows the problem/enhancement,  as an attachment in a zip file. It will be much easier for me to fix.

Enjoy and hope it helps!

Comments

This discussion has been closed.