Deleting Unused Styles

I frequently edit books that are compilations of articles by various authors. Some know how to use Word pretty well; others don't have a clue. Those in the latter category either don't use paragraph styles or create styles that aren't needed. After I've fixed and consistently applied the styles I need, I like to get rid of the other unused styles the authors have created. The following macro seems to do the job quite well. Maybe you'll find it useful:

Sub DeleteUnusedStyles()
'Courtesy of the Editorium
'www.editorium.com
For Each sty In ActiveDocument.Styles
If sty.BuiltIn = False Then
If sty.InUse = False Then
sty.Delete
Else
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles(sty)
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found = False Then sty.Delete
End If
End If
Next sty
Selection.HomeKey Unit:=wdStory
End Sub

If you don't know how to use such macros, you can learn how here:

http://lists.topica.com/lists/editorium/read/message.html?mid=1706922855

You'd think the macro could be a lot shorter:

For Each sty In ActiveDocument.Styles
If sty.BuiltIn = False Then 'Ignore built-in styles
If sty.InUse = False Then sty.Delete
End If
Next sty

But Microsoft Word, ever uncooperative, considers any style that has *ever* been used in a document to be "in use," even if the text formatted by that style has long since been deleted. That means a style can be "in use" even if it's not applied to text anywhere in the document. So, to see if a style is *really* in use, we have to search for text using that style. If no such text is found, then we know that the style really isn't in use and can be deleted.

Note that the macro completely ignores Word's built-in styles, since these *can't* be deleted.

_________________________________________

READERS WRITE

After reading last week's article on pasting tracked revisions, Hilary Powers responded to the last paragraph in the article, which read, "But maybe, just maybe, it's a feature, giving you a choice about whether or not to copy and paste revisions. But if that's true, why not copy revisions when tracking is on, and *not* copy revisions when tracking is off? That would be more logical. Shoot, maybe it is a bug. If so, now you know how to squash it."

Hilary wrote:

It's a feature. Lots of times I'm working along, and I want to pull something from the main document, which has tracking active, to the style sheet--and I want the final version of whatever-it-is, not any changes I may have made in it. That wouldn't be feasible with the apparently logical system. Keeping only the final version is the more likely choice, so it makes sense to have to do something to keep the tracking.

But it's a feature only in Word 2000+; in Word 97, there's a genuine bug: you can't copy tracking AT ALL. If you want to reproduce a passage with tracking intact, you have to bookmark it, then use Insert, File, Range (bookmark name) to put the bookmarked passage into a file that has tracking turned off. (If you want the whole file, you can simply Insert it without the Range bit.)

------------------------

Several readers responded to my answer to Wallace Sagendorph's superscript problem in last week's newsletter, including Mary Eberle, Eric Fletcher, Shirley S. Ricks, and Iwan Thomas. Eric Fletcher wrote:

I bet I won't be the only one to let you know about a much easier method to solve Wallace Sagendorph's superscript problem!

I would just change one instance manually, then select and copy it. Then, in the F&R dialog, put "m3" in the Find what and "^c" in the Replace with. The caret c replaces each instance found with the content of the clipboard.

Of course, your two-step method works for the general case but I'd be a little hesitant to use it unless I was pretty sure the manuscript didn't include other constructions that would get messed up. For example, H2O would end up with a superscript 2 with your wildcard method. I once discovered (luckily just before press!) that the 2 in all instances of "V2 rocket" had inadvertently been changed to a superscript because of an earlier fix to km2.

I really like the "Highlight all items" feature of Word's Find dialog as a tool to easily check the total number of items about to be changed. If it looks a bit too high or I'm not sure, I tick it to cause all found items to be highlighted, drop out of the dialog, copy and then paste into a new Word document. This gives me a list of all found items that is easy to sort or review before committing to the replace. We've done several jobs where URLs and email addresses are sprinkled throughout the ms. I tag them with "URL text" character styles (displayed in purple during editing). Not only is it easier to see this way, but the "highlight all/copy/paste to new doc" procedure gives me a sortable list of all such items--always very handy for confirming currency of such items. I also use a similar method for pulling all citations for easier checking.

Many thanks to Hilary, Mary, Eric, Shirley, and Iwan for their excellent tips and comments.

_____________________________________________________

NEED HELP?

If you need help with Microsoft Word, there are actually lots of places to go. Some of the best include:

The Word-PC List:

http://listserv.liv.ac.uk/archives/word-pc.html

The McEdit list:

http://groups.yahoo.com/group/McEdit/

Microsoft's Word discussion groups:

http://www.microsoft.com/office/community/en-us/FlyoutOverview.mspx#13

(Look in the lower right of the page.)

The Word MVP site:

http://word.mvps.org/

Woody's Lounge:

http://www.wopr.com/cgi-bin/w3t/postlist.pl?Cat=&Board=wrd

But if you can't find what you need in those places, send your question here:

mailto:help [at symbol] editorium.com

I'll put your question in the newsletter to see if some astute reader knows the answer.

Pasting Tracked Revisions

One of the oddest things in Microsoft Word is its seeming inability to copy and paste text that includes tracked revisions. If you want to see what I'm talking about, try this:

1. Create a new document.

2. Type a few lines of text.

3. Turn on revision tracking. (Double-click the TRK box in the status bar so the TRK turns black. Yep, TRK stands for "tracking." At this point, the Reviewing toolbar should appear at the top of your Word window.)

4. Delete a few words here; add a few words there. You'll see your revisions in color, since they're tracked.

5. Copy some text that includes tracked revisions.

6. Create a new document.

7. Paste your text into the new document.

Hey, where are the tracked revisions? Well, they didn't get copied (and thus didn't get pasted). But what if you really need to copy them?

As usual, there's a trick.

Just turn *off* revision tracking *before* copying the revised text. (Double-click the TRK box in the status bar so the TRK turns gray.) Then, when you paste the text (into a document with tracking turned off), all of your revisions will be there.

Why do you suppose Microsoft made Word that way?

A bug? Could be.

But maybe, just maybe, it's a feature, giving you a choice about whether or not to copy and paste revisions. But if that's true, why not copy revisions when tracking is on, and *not* copy revisions when tracking is off? That would be more logical. Shoot, maybe it is a bug. If so, now you know how to squash it.

_________________________________________

READERS WRITE

After reading our last article, "Indexing with a Two-Column Concordance," Patrick LaCosse wrote:

Why bother going through the extra step of delimiting styled paragraphs with certain characters (i.e., "<>")? The style itself is sufficient. Here is an example to show what the logic might be:

Set d = ActiveDocument

Set a = Documents.Add

d.Activate

Selection.HomeKey Unit:=wdStory

With Selection.Find

.ClearFormatting

.Style = "Author" 'Change this to the style of your choice

.Text = "" 'Include specific text if you like

.Wrap = wdFindContinue

.Execute

While .Found

a.Range.InsertAfter Selection.Text

.Execute

Wend

End With

[Note: The simplicity of that macro is deceiving; it's an extremely useful tool. If you don't know how to use such macros, you can learn how here: http://lists.topica.com/lists/editorium/read/message.html?mid=1706922855.]

------------------------

Wallace Sagendorph wrote:

Even after poring over your excellent "Advanced Find and Replace in Microsoft Word" article I still can't quite find an answer to my problem:

In a long scientific paper an author writes "m3" when in fact "m^3^" (where the 3 is in superscript) is intended. The editor says "OK, I will just find all instances of "m3" and replace them with "m^3^." Not so fast! Using the font menu in "find and replace" and changing the "replace" 3 in "m3" to superscript, the result is ^m3^--that is, the entire expression is superscripted. The editor can just enter 3 in "find" and a superscripted 3 in "replace," but that necessitates finding every 3 in what we said was a long document and replacing only those that are exponents of "m"--drudgery!

I'm sure there's a way to use "find and replace" to change m3 to m^3^, but I'm not quite sure what it is. When you have a moment, I and perhaps others of your readers would appreciate learning the secret.

I responded:

This requires what I call a two-step find and replace. The basic technique is outlined here:

http://lists.topica.com/lists/editorium/read/message.html?mid=1706553959

In your case, search for "m3" and change it to something like "m3~"

Then search for "3~" and replace it with "3" formatted as superscript.

You can also do a wildcard search that will catch any such combinations:

Find What:

([a-z][0-9])

Replace With:

1~

Then:

Find What:

([0-9])~

Replace With (formatted as superscript):

1

[You can get "Advanced Find and Replace in Microsoft Word" here: http://www.editorium.com/ftp/advancedfind.zip.]

------------------------

Yateendra Joshi wrote:

A useful way to cross-check whether the specified formatting is being correctly implemented--at least the spacing part of it--is to check the At value in Word's status bar [at the bottom of the Word window]. We use a table that gives the correct value for different "zones" or positions: for example, if the cursor is in a header, the status line should show At 6mm; if in a footer, At 269mm; if in the first line of text following a chapter title, At 45mm and so on. Any departure from these values is a signal to check top and bottom margins, line spacing, and Spacing Before / After.

Many thanks to Patrick, Wallace, and Yateendra for their excellent tips and questions.

_________________________________________

RESOURCES

Yateendra Joshi, who sent that last tip in Readers Write, above, is the author of a terrific book, "Communicating in Style." Editors, especially, will find the detailed explanations of seldom-discussed topics to be worth reading. And you can read a sample chapter (and learn more about the book) here:

http://www.teriin.org/pub/books/cs.htm

As the Web site says:

The handbook is a handy reference whenever you find yourself looking for answers to questions such as those listed below, which arise routinely in communicating technical information formally.

What should a list such as this use to mark off items: bullet points, numbers, or letters?

Where do you cite the source of unpublished data: within the document or at the end, under references?

Which font makes it easier to tell apart such similar-looking pairs of characters as a zero (0) and the letter 'o', the numeral one (1) and the letter 'ell' ('l')?

How are web pages cited when they are referred to in a document?

The main text consisting of explanations, suggestions, and descriptions is amply supported by 90 examples and nearly 150 quotes (from both printed sources and web pages) as well as references, figures, and useful resources (web sites, software, and templates). Separate chapters are devoted to different forms of text such as headings, lists of bullet points, abbreviations, tables, illustrations, references, presentations, posters, and punctuation. Useful annexes cover such matters as observing and using fonts, format for postal addresses and telephone numbers, and alternative spellings.

http://www.teriin.org/pub/books/cs.htm

Indexing with a Two-Column Concordance, Part 2

In last week's newsletter, I promised to show you the perfect example of when to use a double-column concordance in preparing an index, and an automatic way to create such a concordance. The perfect example is a poetry anthology, but almost any consistently structured compilation of articles or addresses will lend itself to this kind of indexing.

Let's say you've got that poetry anthology in front of you on the screen--"100 Poems to Brighten Your Day." As you look through the anthology, you notice a consistency in the way the poems are laid out:

Title

Author

Poem

For example:

Your Day

Jack M. Lyon

Roses are red;

Violets are blue;

This is a day

especially for you.

How inspiring!

And of course, the anthology was edited by an astute editor (probably you) who used paragraph styles for each text level:

Heading 1 (for the title)

Heading 2 (for the author)

Poem First Line (for the poem's first line)

Since this is a poetry anthology, you'll need to create at least three indexes:

Index of Titles

Index of Authors

Index of First Lines

Let's start with the titles. Since they've been styled as Heading 1, you can easily pull them out to put them in a concordance:

1. Click Edit > Replace.

2. Make sure your cursor is in the Find What box.

3. Click the More button if it's available.

4. Click the Format button.

5. Click Style.

6. Scroll down to Heading 1 and select it.

7. Click the OK button.

8. Move your cursor to the Replace With box.

9. Enter "<^&>" (without the quotation marks). That code in the middle of the angle brackets, ^&, is the "Find What Text" code, which you can learn more about here:

http://lists.topica.com/lists/editorium/read/message.html?mid=1703525514

10. Click the Replace All button.

All of your poem titles should now be enclosed in angle brackets:

Now install my Puller program (use it free for 45 days), which makes it easy to pull delimited items into a separate document:

http://www.editorium.com/puller.htm

Use Puller to pull the items in angle brackets (the poem titles) into a separate file, which will look something like this:

Use Word's Replace feature to find "<" and replace it with nothing, then ">" and replace it with nothing, leaving just the list of titles:

Your Day

The Birds Are Singing

Sunshine and Lollipops

A Smile for You

Now put the titles into a table:

1. Click Edit > Select All.

2. Click Table > Convert > Text to Table.

3. In the dialog box, under "Separate text at," make sure "Paragraphs" is selected. Make sure "Number of columns" is set to 1.

4. Click the OK button.

Your titles will now be inside a single-column table. But this is supposed to be a double-column concordance. Why? You'll see. First, make it so:

1. Put your cursor inside the table.

2. Click Table > Select > Column.

3. Click Edit > Copy.

4. Put your cursor to the right of (and outside) the table's first row. (Just click there with your mouse and make sure nothing is selected. You should see just your regular, thin cursor to the right of the table's top row.)

5. Click Edit > Paste Columns.

There! Two columns! And you'll need two columns, because the second column tells Word how to index what's in the first column. For example, you're going to want to lose those initial articles:

The Birds Are Singing Birds Are Singing

A Smile for You Smile for You

Thus, in the finished index, the titles will look like this:

Birds Are Singing

Smile for You

Sunshine and Lollipops

Your Day

Here's an easy way to get rid of those initial articles:

1. Select the second column by putting your cursor into it and clicking Table > Select > Column.

2. Copy the column (Edit > Copy).

3. Create a new document (CTRL + N).

4. Paste the column into it (Edit > Paste).

5. Select the column in the new document.

6. Click Table > Convert > Table to Text.

7. Click the OK button.

8. For each article you want to get rid of ("The," "A," "An," and so on), search for a paragraph return followed by the article (^pThe ) and replace it with a carriage return (^p). This will miss an article on the first item in your list, so you'll need to remove that one by hand.

9. Select your edited list.

10. Convert the list back to a table.

11. Copy the single-column table.

12. Switch back to your document with the double-column concordance.

13. Select the second column.

14. Paste the edited column over the selected column.

15. Save your concordance with a name like "Title Concordance."

Next, you'll need to make a concordance of authors. Just follow the instructions above, searching for Heading 2 rather than heading 1. You'll end up with a double-column table that looks like this:

Jack M. Lyon Jack M. Lyon

Ima Happy Ima Happy

Sonny Day Sonny Day

What you really want, however, is a concordance that looks like this:

Jack M. Lyon Lyon, Jack M.

Ima Happy Happy, Ima

Sonny Day Day, Sonny

The easiest way to get one is to follow steps 1 through 7 in the instructions immediately above. That will give you a list of names, not in a table, and you can use my free NameSwapper macro to transpose the names with last name first:

http://www.editorium.com/freebies.htm

To get your list of names back into the concordance, follow steps 9 through 14 above. Then save your concordance with a name like "Author Concordance."

You can repeat all of this for the index of first lines, although you may not need to change anything in that second column. Up to you!

When you're finished, create your index, using each concordance to automatically mark index entries:

1. Click Insert > Index and Tables > Index > AutoMark. (In Word 2002 and

later, click Insert > Reference > Index and Tables > Index > Mark

Entry.)

2. Navigate to your concordance file and click it to select it.

3. Click the Open button and wait while Word marks all of those index

entries.

4. Generate your index as explained here:

http://www.topica.com/lists/editorium/read/message.html?mid=1714065147

If you're doing a poetry anthology, you'll probably also need an index of topics. Unfortunately, there's no good way to automate that. Instead, you'll need to use your indexer's brain. But maybe the techniques explained in this article will help when you do have items that can be indexed automatically.

_________________________________________

READERS WRITE

Editing and Microsoft Word expert Geoff Hart wrote to suggest that I might want to make a further clarification about what a concordance is. When I say concordance, I'm not talking about a back-of-the-book index, such as an index of topics in a poetry anthology or an index of subjects in a textbook. In my opinion, such an index can be created only by a human mind. As Geoff wrote:

"An indexer examines each occurrence of a word and communicates why that occurrence is important by providing context. For example, 'Washington, George' (in a concordance) becomes "Washington, George--birth of, --death of, --election of" and so on in an index. Similarly, an indexer provides cross-references (e.g., President: see Washington), synonyms (Walstein: see Washington -- here, a fictitious example assuming that George Walstein changed his name to George Washington to make it more likely he'd be elected ), and so on. The index is clearly more useful, but is also enormously more difficult to create.

"I'm a half-decent indexer, but stand in awe of the real pros like Lori Lathrop, who provide an almost magical means of access to a large book. A concordance can help a professional indexer in their work, but it can't take the place of an index, and an amateur shouldn't even attempt this task without doing some study to learn how it's done. The Chicago Manual of Style provides a decent introduction to indexing."

In last week's newsletter, I mentioned two definitions for "concordance":

1. A list of all words in a document, to be used as an aid in editing.

2. A list of words used to create an index, as explained in today's article.

Geoff is suggesting one more definition:

3. A list of every word in a document and the *pages* on which that word appears.

This kind of concordance is most commonly seen in the back of certain editions of the Bible, making it possible for readers to look up any word used in the Bible and find the places in the text where that word is used. Again, let me emphasize that this is not the same as a back-of-the-book index. A concordance can be created by a computer; an index can be created only by a human mind.

Of course, the human mind can use a computer to *help* with the creation of an index, and I'm pleased to announce that the indexing program I've been working on for more than a year is nearly ready for release. I'll be making an "official" announcement and description of the program soon in this newsletter, so stay tuned. In the meantime, I'll just mention that the program is a Word add-in that allows you to select specific document text from *here* to *there*; press a key to create an empty row in a Word table in an accompanying document; type your index heading, subheading, cross-reference, and so on into the row; rinse and repeat until your index is finished; edit as needed; automatically embed Word index entries based on the table you've created; and finally generate the index and page numbers (locators), with the option to sort word by word or *letter by letter.* Index subheadings can also be sorted *by page.* You can see all of your entries at all times in the index table; no more indexing in the dark, and no more working directly with embedded commands. If you like, once the table has been created, you can import it into Cindex or other dedicated indexing programs for final processing, *without* having to type in page numbers. I've tried to build in plenty of power and flexibility for all. The program has many more features, and I'll be explaining what those are in the near future. *If you have suggestions* about what you'd like to see in the program, *please* let me know, and soon!

mailto:editor [at symbol] editorium.com

Many thanks to Geoff for his clarifying comments and for the opportunity to plug my forthcoming program.

_________________________________________

RESOURCES

I recently learned about DesignGeek, which is a newsletter sort of like Editorium Update but written for people who inhabit that alternative universe of designers! If you spend part (or all) of your time in that universe, you'll definitely want to check out DesignGeek, which offers the same kind of useful, gritty, real-life tips and instruction you enjoy (I hope) in Editorium Update:

http://senecadesign.com/tips-pubs/designgeek.html

The Web site says:

"DesignGeek is a free e-mail newsletter written by Anne-Marie 'HerGeekness' Concepcion, president of Seneca Design & Training. Coming at you every couple weeks or so, each issue contains about a page's worth of her newest finds: advanced tips, techniques, links, and late-breaking news for Mac and PC designers who use the world's coolest software: InDesign, QuarkXPress, Photoshop, Acrobat, Illustrator, GoLive, Dreamweaver and more.

As I started to explore this site, I was blown away by how much Anne-Marie knows that I don't. There's stuff here I've never even heard of. Pixel fonts? Cool! "HerGeekness" indeed! I'm going to be reading and learning here for a long time to come. Enjoy!