Thread: [Solved] HELP: Binary page numbering
View Single Post
 
Old 03-26-2014, 08:04 PM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The following field code will produce binary page numbering for up to 255 pages:

{QUOTE{SET Binary "{=MOD(MOD(INT({PAGE}/128),256),2) \# 0}{=MOD(MOD(INT({PAGE}/64),128),2) \# 0}{=MOD(MOD(INT({PAGE}/32),64),2) \# 0}{=MOD(MOD(INT({PAGE}/16),32),2) \# 0}{=MOD(MOD(INT({PAGE}/8),16),2) \# 0}{=MOD(MOD(INT({PAGE}/4),8),2) \# 0}{=MOD(MOD(INT({PAGE}/2),4),2) \# 0}{=MOD({PAGE},2) \# 0}"}{=Binary \# 0}}

Doubling, quadrupling, etc the number of pages catered for is as simple as adding more of the {=MOD(MOD(INT({PAGE}/X),Y),2) \# 0} fields to the start of the (SET Binary "} field, doubling the X and Y values each time. Equally, you can delete unwanted terms, starting from the same end.

If you don't mind having leading 0s, you could use:
{QUOTE"{=MOD(MOD(INT({PAGE}/128),256),2) \# 0}{=MOD(MOD(INT({PAGE}/64),128),2) \# 0}{=MOD(MOD(INT({PAGE}/32),64),2) \# 0}{=MOD(MOD(INT({PAGE}/16),32),2) \# 0}{=MOD(MOD(INT({PAGE}/8),16),2) \# 0}{=MOD(MOD(INT({PAGE}/4),8),2) \# 0}{=MOD(MOD(INT({PAGE}/2),4),2) \# 0}{=MOD({PAGE},2) \# 0}"}

Note: The field brace pairs (ie '{ }') for the above example are all created in the document itself, via Ctrl-F9 (Cmd-F9 on a Mac); you can't simply type them or copy & paste them from this message. Nor is it practicable to add them via any of the standard Word dialogues.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote