Number Your Pages Visually
It’s nice to let your audience know where they are in a document, and how much further until the end. This is especially true if your Visio document does double-duty as a presentation.
A progress bar-style graphic does a nicer job of this than “Page 1 of 4″ or “Page 3/4″ or “75%”. The audience gets a real feel for how much is complete and how much remains.
Today’s article will show you some ShapeSheet techniques for creating a visual page-numbering shape. We’ll modify the Circle-text Title shape from an earlier Visio Guy article so that it shows you how far along you are in a document. You’ll also learn how to get the shape to position itself automatically on the page, so that it is even easier to use!
So go get a fresh cup of coffee and read on!
Start With Something Old…
If you’ve read the recent post: Run Circles Around Your Text With the Circle-text Title SmartShape, then you know how easy it is to create graphics like this:
using the Circle-text title shape. For every character you type, a nice and tidy circle appears around it.
An interesting feature of this shape is that even spaces will show up inside of circles. If you type “fat cat”, you will get seven circles.
…Create Something New: A Visual Page Numbering Shape
That “space concept” is what triggered the idea for the visual page numbering shape. Spaces could be used as place holders, thus allowing a progress-bar graphic to be created from the Circle-text Title shape.
To illustrate the concept, have a look here:
Bullets show the page number, spaces show the remaining pages. Voila! We’ve got a page-numbering progress bar!
The only problem remaining was how to get bullet characters and spaces to repeat themselves automatically.
If you’re good with Visio’s ShapeSheet, this isn’t too hard to do. But if you are new to making SmartShapes (and are curious, and find it a little bit addicting), then this is a good little exercise to learn some ShapeSheet formulas and some tactics for creating shapes.
Analyze Your Document’s Pages
There are two ShapeSheet functions that help you “do page numbering”. PAGENUMBER() tells you what page you are on, and PAGECOUNT() tells you how many pages are in your document, excluding background pages.
Incidentally, these two functions coincide with fields that you can enter via the Insert > Field dialog. When you insert these fields using that dialog, Visio puts these formulas into Text Field Section cells inside of the ShapeSheet.
Because I like to have my custom logic in as few places as possible, I added two User-defined cells to my Circle-text Title shape to hold page-metric data:
User.pg = PAGENUMBER() User.pgs = PAGECOUNT()
The value returned by PAGENUMBER() in User.pg depends on which page the containing shape is on. Once we get the logic correct, and the text hooked up, we’ll only need to drop this shape inton any page in the document, and the dots and circles will automatically work!
Create Repeating Text
The Circle-text Title shape shows circles for as many characters as are typed into its text block. That means we need bullets up to the page we are on, and spaces for the pages that come afterwards. Ie:
# of bullets + # of spaces = # of pages
Visio has a nice ShapeSheet function for repeating text. It is oddly named: “REPT”, and takes a string and a number as arguments.
= REPT(“Bob”, 4)
will give you:
To get the proper text, I inserted another User-cell, then made use of the REPT function twice: once for the bullets, and once for the spaces:
User.txt = REPT("o",User.pg)&REPT(" ",User.pgs-User.pg)
You can see how User.pg and User.pgs were used to calculate the number of repeats necessary. The effect is to create strings like this:
Page 1/4: o _ _ _
Page 2/4: o o _ _
Page 3/4: o o o _
Page 4/4: o o o o
Note: in the User.txt formula above, I’ve shown a lower-case “0”, but a bullet works a lot better. The circular bullet seems to be more centered and more circular, where o’s can be slightly off-center and oval.
To get a bullet character, you can just go to Visio’s own: Insert > Symbol menu, or fire up Character Map under Start > All Programs > Accessories > System Tools.
Show the Smart Text on the Shape
Once User.txt is up-and-running properly, we just need to link it to the shape’s text. This is simply a matter of inserting a text field that refers to the cell.
To link a user-cell to a shape’s text, just select the shape and start typing or just hit F2 to enter text-edit mode. Then click the menu: Insert > Field > User-defined cells, and choose User.txt from the list of possible cells.
Since your Circle-text Title shape now has smart text, linked to ShapeSheet calculations, it is also a good idea to protect the text from being edited by the user. You can protect the shape against text edits by clicking the Format > Protection menu, then checking the Text check-box. Now users won’t be able to stomp all over your carefully crafted smarts!
Place the Shape Automatically
A page-numbering shape is a kind of title-block shape, or a foot-note, or a header of sorts. That means it should always appear in the same place on a page to ensure visual consistency. If you’ve got a lot of pages in your document, you’ll have to paste the shape, then carefully place it many, many times. This could get tedious.
But with some clever ShapeSheet formulas, you can get the positioning to take care of itself. Then you just have to paste-paste-paste!
The following sets of formulas show you how to get a shape to anchor itself in one of the four corners of a page. The PinX and PinY cells control the position of the shape, and their formulas are GUARDed so that the shape automatically positions itself, and can’t have its position altered (or the formula blown away!)
PinX = GUARD( User.Margin) PinY = GUARD( ThePage!PageHeight - User.Margin ) LocPinX = Width * 0 LocPinY = Height * 1 User.Margin = 0.25 in
PinX = GUARD( ThePage!PageWidth - User.Margin ) PinY = GUARD( ThePage!PageHeight - User.Margin ) LocPinX = Width * 1 LocPinY = Height * 1 User.Margin = 0.25 in
PinX = GUARD( User.Margin ) PinY = GUARD( User.Margin ) LocPinX = Width * 0 LocPinY = Height * 0 User.Margin = 0.25 in
PinX = GUARD( ThePage!PageWidth - User.Margin ) PinY = GUARD( User.Margin ) LocPinX = Width * 1 LocPinY = Height * 0 User.Margin = 0.25 in
The LocPinX and LocPinY cells specify where the anchor point of the shape is. To avoid having to subtract-off or add-on half of the shape’s width and/or height, we just move the location of the “loc pin” around to simplify the PinX and PinY formulas.
Also, I’ve thrown in parameter “User.Margin” to keep the shape from being in the non-printing area of the page. By creating this variable, it will be easier to change the margin setting in the future, without having to check through many cells and formulas for hard-coded values.
Once I had all the text and location smarts working, it was child’s play to copy and paste the shape into many pages. Below is a six-page document. It took about five seconds to duplicate the page-numbering shape onto each page. The purple dots updated automatically, and I didn’t have to fuss with the location of the shape at all.
If you like the way this automatic page location works, you can see another example of it in this article: Design Web Pages With This Visio Breadcrumbs Shape.