Hack 42 Corral Basic Bullets and Numbering![]() ![]() best of all, predictable built-in styles for making bulleted and numbered lists. So how come they've got nothing to do with those decidedly unpredictable list buttons on the toolbar? Here's how to hack some more helpful buttons.Admit it: the first time you ever clicked one of those little list buttons, you were impressed. Bullets! Numbers! Indented and aligned! How do they do that? Not very well, as it turns out.What happens when you press one of those buttons depends not on the document you're using, nor on the template on which the document is based. It doesn't even necessarily depend on what happened the last time you clicked the button. It depends on which one of the seven different available list formats you last chose from the Format Figure 4-23. When you click the Bullets button on the Formatting toolbar, it will apply the formatting selected here![]() same seven each time. Which of the seven you last chose is stored in the Windows registry, a massive internal database Windows uses to store information. If you click the same button, in the same document, on two different computers, it can yield different results. Still impressed? It gets worse. Once you've gone through the trouble of populating a long document with lists by using the Bullets or Numbering toolbar buttons, there's no easy way to globally change how those lists are formatted.Most Word pros avoid these two buttons like the Plague. They prefer to use a paragraph style to include lists in a document. If you use paragraph styles, you can modify every paragraph that uses a particular style at the same time. For the same reason, many power users eschew the Bold and Italic buttons in favor of the Strong and Emphasis character styles (see [Hack #39] ).Word provides a boatload of built-in list styles for you. In addition to the 10 bullet and numbering styles, Word has 10 more for nonnumbered lists and list-continuation paragraphs. The list styles all come factory-set with some basic formatting (the "List Bullet 2" style is indented more than the "List Bullet" style, for example). You can see a few of these styles in Figure 4-24. The five List Bullet styles, as they're formatted by default, are shown in Figure 4-25. Figure 4-24. Word includes several dozen built-in list styles![]() Figure 4-25. The built-in list styles are already indented proportionally![]() far as to actually remove the list buttons from the Formatting toolbar. So the buttons get used anyway, especially for short documents and, unfortunately, for long documents you thought were going to be short.By intercepting some built-in commands [Hack #61], you can reeducate those buttons (along with the Increase Indent and Decrease Indent buttons) to apply Word's predictable and reliable built-in list styles, which you can easily modify as needed in your documents or templates. 4.17.1 Mapping the Styles to the ButtonsIn addition to the Bullets and Numbering buttons, this hack also intercepts the Decrease Indent and Increase Indent buttons. These four buttons, shown in Figure 4-26, sit adjacent to each other on the formatting toolbar. Figure 4-26. The Four Buttons of the Apocalypse![]() built-in bullet and numbering list styles (List Bullet, List Bullet 2, List Bullet 3, List Bullet 4, List Bullet 5, List Number, List Number 2, List Number 3, List Number 4, and List Number 5).When you implement this hack, the action taken when you click each of the four buttons will depend on the style currently applied to the selected text. For example, if you select text styled as "List Bullet 2," the following will happen when you click each of the four buttons: Change back to Normal Change to "List Number" Change to "List Bullet 3" Change to "List Bullet" To implement this hack, you must create a fairly lengthy description of which style gets applied for which button. Fortunately (for you, not the author), that's already been done, so the code below will work straight out of the box, so to speak. 4.17.2 The CodeThis hack is a combination of five separate macros: one that makes the decisions and applies the formatting, and four others that intercept the commands used by the four toolbar buttons. Each of the macros used to intercept the buttons "calls" the fifth macro, the one that does the formatting, and "tells" it which button was clicked.The selected text will always be in one of 11 possible states: either one of the 10 list styles, or some other style altogether. For each scenario, you can take four possible actionsone for each button.These are the four macros that intercept the buttons. Put these, along with the BetterBulletsAndNumbering macro that follows, in the template of your choice [Hack #50] . Sub FormatBulletDefault( )
applying it to the selected text. To efficiently handle such a large number of options, this code uses VBA's Select Case statements, a much neater alternative to a massive set of complex If... Then... Else statements. Function BetterBulletsAndNumbering(ByRef sel As Selection, _This code has two important features:Sometimes you might click one of the indent buttons when you've selected text that isn't part of a list. In that case, the macro just "passes" the command on to Word, which will indent as it would if the button had never been intercepted.If you select multiple paragraphs with different styles applied, the code loops through and formats each paragraph in the selection separately, using a For Each loop [Hack #66] . 4.17.3 Running the HackOnce you've placed these macros in an active template, they'll spring into action when you click any of the four toolbar buttons shown in Figure 4-26.If you want to change the formatting of the bullets or numbering, modify the corresponding built-in list style. |