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

Fancy Sorting

Back in my WordPerfect days, I used to enjoy the program's ability to do all kinds of fancy sorting. Microsoft Word has never been able to duplicate that, but it can still do more than you might think.

Let's say you've got a list of names, like this:

Kit Carson

Annie Oakley

Buffalo Bill

You probably know that you can sort them by first name under Table > Sort. But what if you want to sort them by last name? Yes, it *is* possible. Here's how:

1. Select the list.

2. Click Table > Sort.

3. Click the Options button.

4. Under "Separate fields at," select "Other."

5. In the box next to "Other," type a space (indicating the space between first and last names).

6. Click the OK button to go back to the "Sort Text" dialog.

7. Under "Sort by," click the drop-down arrow and select "Word 2."

8. Under "Then by, click the drop-down arrow and select "Word 1."

9. Click the OK button.

Your list should now be sorted like this:

Buffalo Bill

Kit Carson

Annie Oakley

Pretty slick!

What if some of your names have more than three parts?

Samuel Langhorne Clemens

Simple. Sort by Word 3, then Word 2, and then Word 1. Word lets you sort by up to three words, in any order, as long as they're separated by the same character (such as a tab, comma, or space). It may not be Perfect, but it's probably better than you thought.

_________________________________________

READERS WRITE

After reading the articles on Editing by Concordance in the past couple of newsletters, Meg Cox wrote:

"This is great stuff!

"My plan is emerging here. (You can include this in the newsletter if you want, Jack, but I haven't tried it all yet. Either way, if you see any holes in this process, tell me).

"1) Run Word Counter and go through the concordance and MegaReplacer process to make obvious changes. This would have been wonderful for fixing British spellings in this project (nearing completion) and the previous one. Take note of items that look troublesome but that I'll need to decide about when I encounter them in context.

"2) Use my indexing software to construct my style sheet as I work through the book. (But begin by entering items from the concordance file that I know right off the bat need to be on the style sheet. I can create a tab-delimited file with the necessary items from the concordance and import it to save on typing or copying and pasting.) Using the indexing program is necessary because the concordance won't help me with items that are more than one word, and with the software I won't have to navigate to the right spot on the style sheet to compare new terms with earlier entries--the style sheet sorts itself in the top of the window as I enter terms at the bottom.

"3) Note already-checked terms by finding and replacing to add different formatting or highlighting that I can remove later. Here there will be two levels: For references, I should do this while I still have all chapters combined. Then I can separate the chapters and use the same process to indicate, for example, whether an organization with an acronym has appeared spelled out yet in the chapter, and whether a person has appeared yet with both first and last name in that chapter. In the case of end-of-chapter notes I would also somehow need to revisit the references and use the highlighting method to check for use of a full citation first time and short cite thereafter. I'll have to think about how to do that."

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

Paul Robinson wrote:

"I edit in Word. After finishing a document, I calculate percentage mark-up by comparing a word count of the original document with a word count of the marked-up document. But this tells me only how many words I've added. I'd really like to be able to see how many words I've deleted as well. Then I could measure the heaviness of the editing by looking at the extent of both inserted and deleted words.

"At present I count characters-with-spaces in the original text and then in the text with tracked changes. This gives me a very rough, comparative idea of the extent of the editing. To be able to count the number of inserted/deleted words (the revised words in total) would be a definite advance. To be able to count the inserted and deleted words separately would be even better! One could then report to a client as follows. "The editorial changes required were heavy (or light, as the case may be): insertions = m% of original word number, deletions = n% of original word number, which compares with my averages thus . . ." Moreover, one could suggest, if the number of deletions, say, was high, that the client was writing in a rather ponderous style; and so on--with all due tact, of course!"

Thinking that Paul has a great idea here, I created the following macro, which provides a count of both insertions and deletions. If you don't know how to use such a macro, you can learn how here:

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


Sub CountRevisedWords()
Dim RevCount, WordCount, RevType, InsertedWords, DeletedWords, r
RevCount = ActiveDocument.Revisions.Count
For r = 1 To RevCount
WordCount = ActiveDocument.Revisions.Item(r).Range.Words.Count
RevType = ActiveDocument.Revisions.Item(r).Type
If RevType = 1 Then InsertedWords = InsertedWords + WordCount
If RevType = 2 Then DeletedWords = DeletedWords + WordCount
Next r
MsgBox "Inserted words:" & Str(InsertedWords) & " Deleted words:" & Str(DeletedWords)
End Sub

Many thanks to Meg and Paul for their terrific comments.

Editing by Concordance, Part 2

Last week's newsletter explained some ways a concordance could be used in editing, with a promise that this week I'd show you a sneaky way to take that concept even further. So here goes.

There you are with a manuscript that needs editing, and lots of it. A cursory look reveals multiple inconsistencies and odd spellings, and you're going to have to fix them all. What to do? Try this:

1. Use our WordCounter program or the MakeConcordance macro in last week's newsletter (scroll down to the end of Readers Write) to create a concordance, or word list, of all the words in the document.

You can download WordCounter here:

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

And you can read last week's newsletter here:

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

This time around, you don't need to worry about word frequency (although you can if you find that helpful). Instead, just make a list that looks like this:

and

managment

manger

of

the

And so on.

You could go through the list and manually delete all the commonly used words (such as "and," "of," and "the"), leaving you with the words you actually need to think about, but that would take a long, long time. A better way would be to use our MegaReplacer program to remove the commonly used words:

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

And you could do that if you just had a list of commonly used words. You can download one here:

http://www.editorium.com/ftp/commonwords.zip

The list contains 2,256 entries (compiled from various sources) and is already set up for use in MegaReplacer. So use the list with MegaReplacer to delete all of the commonly used words from your word list, leaving you with just the real stuff.

Once you've got the real stuff (such as "manger" and "managment"), you'll find it much easier to go through the list and decide what needs to be changed. Please do so. As you find words like "managment" that need to be corrected, set *them* up for MegaReplacer as well:

managment|management

manger|manager

The bad goes on the left, the good on the right, with a pipe symbol in between. You may also want to add the good to your editorial style sheet, as explained in the newsletters for April 28 and May 5:

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

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

Aside from misspellings, you'll also find inconsistencies in spelling, style, and capitalization that need to be fixed. Set them up the way you want them to be:

realise|realize

When you come to words that are fine just as they are, add them to your editorial style sheet as needed and then delete them from the list,

When you're finished, you'll have a beautiful find-and-replace list that you can feed to MegaReplacer, which will go through your manuscript and automatically make all the changes you've specified. If this makes you nervous, you should know that you can have the program mark its revisions in case you later have any question about what was changed.

If you're looking for a way to speed up your work, you may find this technique useful. There's one way to find out. And you've got to admit that using a word list to modify a word list to modify a document is pretty sneaky.

_________________________________________

READERS WRITE

Teresa N. Barensfeld wrote:

Another good use for the concordance is for projects with vast reference lists. Sometimes the names are inconsistently spelled in the text or the ref list, but they're so close that it's easy to miss.

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

Dave Gayman wrote:

Meg asked:

"Now I'm wondering: I don't think a Word macro can open a window in another program and order a paste there. That would be very helpful."

Remembering that this was a stopper in a VBA project long ago--and I don't remember if it was because it could not be done, or simply that I could not master the commands to make it happen--I'd suggest MacroExpress (http://www.macros.com/index.htm), $50.

With MacroExpress, you simply record the key or mouse strokes (or both) to accomplish the task. In addition to recording the macro, users are also able to enter macros directly into an edit pane (much of which is done via select and paste) and they are able to edit the code that has been generated automatically. Before the recording begins, a sequence of dialogs lets you make choices, including whether you'll be capturing key strokes, mouse movement, or both; applicability--see next paragraph; hot keys; macro name, and so on.

Macros can be global (that is, work with all programs), program-specific, or window-specific. You can assign hot keys to the macro, as well as assign a password. In Meg's case, once Meg selects the target word, MacroExpress could copy the word, switch to (or launch, if it is not already open) the second window; if necessary position the cursor (for example, at the end); paste; then switch back to the Word window.

I've used MacroExpress to automate or semi-automate the process of eliminating duplicates in a long product order code list by cross-reffing against an Excel file; to set up glossary entries (including both making a new entry and applying of Word styles for formatting); and many small repetitive tasks.

Although I originally bought MacroExpress to create actions in Dragon NaturallySpeaking Preferred edition (a version level without macro capabilities), the order code duplicate finder gave me my $50 in value. It took a project that could easily have consumed three days and telescoped it into about an hour. Note that there is usually a variable amount of debugging to be done to make a macro more generic or to make it do everything you want it to do--the duplicate finder took about half an hour to set up and tweak, all told.

There's a support newsgroup where newbies are generally treated humanely (find it at http://www.pgmacros.com/newsgroup.htm). Users run the gamut from casual operators of the program (like me) to very serious macro wranglers with correspondingly complex automated tasks.

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

Richard H. Adin wrote:

I don't have a within Word answer for Meg, but I do have an answer that will work on a Windows PC: using MacroExpress (http://www.macroexpress.com).

I had three problems that needed solving and I couldn't figure out how to do it within Word:

(1) How to copy a phrase from my text document to a style sheet and, if the phrase had an acronym, how to enter it twice on the style sheet--once as, e.g., World Health Organization (WHO) and then as WHO (World Health Organization);

(2) I'm pretty sure that five chapters ago I had come across the acronym, e.g., WHO, and had spelled it out and added it to my style sheet. Now I've come across it again and it needs to be spelled out here, but I can't recall what it means. I wanted to quickly check the style sheet to see if it was spelled out, and if it was, then copy the spelled-out version and paste it in place in the text file; and

(3) In books that follow the APA reference style (or any similar style) in which the text reference entry appears as, e.g., Smith, Jones, Adams, and Burley (1998), how to (a) verify that the entry is in the references; (b) check for and mark subsequent entries so I don't have to reverify that it exists or is correct each time I come across the entry in the text; (c) mark the entry in the references so I know (i) which references have been cited in the text and which haven't and (ii) I know that I have already checked that the reference is properly styled; (d) if the subsequent text entries are Smith, Jones, Adams, and Burley (1998) when they should be Smith et al. (1998), I can correct the erroneous entries; and, finally, (e) when done, I am returned to where I started.

Although the macros I have written in MacroExpress can yet be improved upon (and I am constantly improving them), they do work well as is. Below are the steps I take to run a macro for each problem.

________________________

Problem 1: To add material to the style sheet:

1. Highlight the material to be added. If it is just a word or a phrase, highlight that; if it is a word/phrase with an acronym, highlight the spelled out word/phrase + the acronym, including the opening and closing parentheses.

2. Press F9 (this just happens to be the key to which I assigned the macro; MacroExpress lets you assign most any key combination).

3. In the dialog box that appears, enter only the place where you want to go. For example, in the WHO example, you want to go to the W section of the style sheet, so enter w and click OK.

4. You will be moved to the W section, and your cursor will blink where it is. BEFORE doing anything else, move the cursor to the beginning of the line where you want your selection to be entered. Do not add a return to make a line. If you already have entries, place the cursor at the beginning of the line that is to appear AFTER this entry is typed.

5. In the dialog box, make the appropriate choice. Choose Word for a word or phrase without an acronym; choose Word + Acronym for a word or phrase that has an acronym that needs to be entered; choose cancel to stop and return to the text file. Once you make your choice, the macro will paste your copied material at the insertion point on a new line. If you chose Word, you will then be returned to where you were in the text file. If you chose Word + Acronym, then

6. The macro will pause and tell you to move the cursor to the beginning of the line where you want the acronym to appear. Again, just move your cursor; do not add a line. When your cursor is in place, click Resume. The macro will paste the entry at the designated position, creating a new line, and will then move the acronym to the line beginning and put the spell out in the parentheses.

7. The macro will automatically return you to your place in the text file.

_________________________

Problem 2: Checking on an acronym

1. Highlight the acronym--just the acronym, not any spaces before or after.

2. Press F10 (again, this was my choice).

3. The macro will take you to the style sheet and will highlight the first instance of the acronym. There is a slight delay so that you can see what is being highlighted in the style sheet, after which a dialog box appears. If the highlighted acronym is the correct one, click Yes; if it isn't, click No. Click Cancel to terminate the macro and return to the text file.

4. If you choose Yes, the cursor will move to the beginning of the spell out and pause.

5. Now highlight the complete spell out, including the acronym and the closing parenthesis, but not the paragraph marker.

6. Click Resume. The macro will return to the highlighted acronym in the text file and replace it with the spell out and acronym in parentheses.

7. If you chose No rather than yes, the macro will search for the next instance of the acronym; if it finds another instance, you will have the same three choices. If it doesn't find it, Word will tell you that it has not been found and ask you whether you want to search from the beginning of the document. Choose yes or no depending on where the search started. If you choose no, then also choose cancel in the Macro Express dialog box. It will cancel the macro, close the Find and Replace box, and return you to where you were in the text file.

_________________________

Problem 3: Reference checker

1. Highlight the first author's surname only (e.g., in Smith and Jones (1995) or Smith, Jones, Adams, and Burley (1998), highlight only Smith).

2. Press F7 (my choice).

3. The macro will take you to the beginning of the reference list and then search for the first instance of the name you highlighted, highlighting the name in the reference (e.g., Smith). A dialog box will appear asking if this is the correct reference. If it is, click Yes. (If you choose no, the macro will find the next instance of Smith.)

4. In the next dialog box, choose whether this is a reference that has either 1 or 2 authors or 3+ authors.

(a) If 1-2 is chosen, the highlighted name in the reference list will be colored green and the macro will then return to the text file and search for the next instance of Smith, which it will highlight. A dialog box will appear and ask whether this is the correct reference. If yes, a marker will be inserted following the name; if no, the macro will search for the next instance of Smith, at which time the dialog box will appear. The process repeats until the macro reaches the end of the document and finds no more instances of Smith, at which time you cancel the macro and are returned to where you began.

(b) If 3+ is chosen, the highlighted name in the reference list will be colored green and the macro will then return to the text file and search for the next instance of Smith, which it will highlight. A dialog box will appear and ask whether this is the correct reference and if it needs to be modified. Your choices are different from those in (a). If the listing is Smith, Jones, Adams, and Burley and it should be Smith et al., you choose Yes (make et al. and mark). If it is already Smith et al. but is the correct reference, you choose No (is et al. but needs mark). And if it is not the correct Smith, you choose Find next so that the macro will not mark this reference and will search for the next instance of Smith. The process repeats until the macro reaches the end of the document and finds no more instances of Smith, at which time you cancel the macro and are returned to where you began.

(c) Because you may have already found this entry and colored it green in another chapter, you can also choose to just search the main text file. In this case, you are returned to the main text file without marking the reference file, and the process proceeds as above.

When you are done editing the document, you simply search for the marker and replace it with nothing.

_______________________

Because I work on a per-page or project fee basis, saving time is important. Do these macros save time? Absolutely. The steps look more cumbersome than they are--it's more difficult to explain the operation than to do it. Although the first two macros can be performed by using your mouse and keyboard to copy, switch between documents, paste, and switch documents again, my experience is that using the macros is much more efficient and faster. Even if I only save a few seconds each time, it adds up.

The third macro is a real timesaver because I accomplish several things simultaneously. (1) I verify that a reference is in the reference list and mark it (green highlight) so that when I get to the end of the project and now only have to check the reference list, I have already eliminated having to check most of the references--I only need to check those without the green highlight. (2) When I send the reference file to the author for review, I can tell the author that only those highlighted in green are cited in the text and ask what the author wants to do with the others. It becomes easy for the author to know which ones I mean. (3) By adding a marker to each occurrence of a reference in the main text, I speed things along because I know I have verified the reference already. It's a little slow in the beginning, but it speeds things as you move further along in the text. Imagine a 50-page chapter with scores of these references. How do you remember that Smith (1995) is OK but that Smith (1998) has not been verified?

MacroExpress has allowed me to make my keyboard more functional and to do things that were otherwise cumbersome. Just two quick examples of what I mean. (By the way, I primarily use Word, so all of the examples are of things that I do in Word. MacroExpress permits you to assign a macro to a specific application or to global, i.e., to every program.) Each of my clients has a different way to do things. Some want me to code with beginning and ending codes such as at the beginning of a bulleted list with at the very end of the list; some want me to apply a Word style to each paragraph; and some want specific codes used in specific series. MacroExpress lets me create different keyboards for different clients, and multiple keyboards for clients whose coding changes based on the series. Once I write a standard macro, for example, one that does the bullet list coding, I can import it into any number of keyboards and modify just the code, without modifying how it works, so that it inserts the codes the client wants.

In the case of the bulleted list, I press F6, and MacroExpress types and adds a bookmark. Then it pauses and tells me to move my cursor to the end of the bulleted list where I want the closing code placed. It doesn't matter whether the end is one line or 100 pages away; I move to it and click Resume, and MacroExpress types and then moves me back to the beginning of the list so I can edit.

I have one client who uses a standardized footnote system, e.g., every time a drug is named that is not FDA approved for the particular indication, the client wants a superscript 1 inserted in the text and then inserted as a new paragraph "1 This drug is not FDA approved for this indication." with the 1 superscripted and the Footnote style applied to the paragraph. With MacroExpress, I was able to write one macro that does it all. I place my cursor where I want the footnote reference inserted, press the assigned key combination, and in a split second it's done and I am returned to where I left off my editing. This ensures uniformity and that I don't forget to do something.

Many thanks to Teresa, Dave, and Richard for their excellent tips and comments.

_________________________________________

RESOURCES

If you're interested in MacroExpress, so wonderfully described in the Readers Write column above, you may also be interested in WinKeySim, which offers some of the same features. WinKeySim, however, is a freeware program for Windows 95 and later and Windows NT 4.0 and later. WinKeySim gives keyboard macro support for practically any Windows program that supports keyboard input. Generally speaking, if it can be done with the keyboard, it can be done with a WinKeySim macro.

http://mwganson.freeyellow.com/winkeysim/

Editing by Concordance

Our previous newsletter mentioned our WordCounter program, which can now tell you how many times each word has been used in a document--and I promised to show you how that might be useful for editing. The newsletter also featured a macro that will create a concordance, or list of all words used, from a Word document. Next week, I'll explain a very sneaky way to use that in editing, so stay tuned.

Let's say you've run WordCounter's concordance feature on a document, including word frequency, so you've now got a report in a table that looks like this:

1,639 and

1,453 the

1,330 of

Notice that the table is sorted by word frequency, with the most frequently used words at the top. That doesn't seem very useful; who cares how many times "and" and "of" appear? On the other hand, it may give you an idea of your author's general verbosity and other faults. Lots of prepositions? As you edit, watch for strings of prepositional phrases. Lots of "is," "was," and "were"? The author's verbs may need strengthening, and you may need to root out the passive voice. Lots of capitalized "And" and "But"? Does it bother you to start a sentence with a conjunction? If not, has the author simply overdone it? How many times is "very" used? Fifty occurrences of "paradigm"? Good grief!

What else can you think of? Please let me know; I'll share your thoughts in the next newsletter: mailto:editor [at symbol] editorium.com

Now let's go to the bottom of the table:

3 manger

2 managment

Hmmm. In this business book, we've got "managment" appearing twice, and "manger" three times. The spell checker would have caught "managment" but not "manger." We now know that we should search for "manger" and replace it with "manager." And we might as well take care of "managment" while we're at it. You'll probably find some pretty strange fish in this end of the net, but without WordCounter, they might have gotten away. Find and replace as needed. If you have lots of them, I recommend fixing them en masse with MegaReplacer:

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

Now let's sort the table alphabetically by word. No, no, wait. First, select all those frequently used words at the top of the table and delete them. That will get them out of the way for what we want to do next. Here's how:

1. Select a whole bunch of words and numbers you want to get rid of.

2. Click Table > Select > Row.

3. Click Table > Delete > Rows.

Okay, *now* let's sort the table alphabetically by word:

1. Put your cursor in the table.

2. Click Table > Select > Table.

3. Click Table > Sort > Column 2, Text, Ascending.

4. Click OK.

Excellent. Now start looking through your list. What do you see? Multiple spellings for "realize/realise"? How about "President" and "president"? Sorting the table by word puts such variations near each other in the list so you can spot them easily. Then, in your main document, you can find and replace as needed.

Knowing how many times each word appears may also help in your decisions about editorial style. If both styles are acceptable, why not go with the one you have to fix the fewest number of times? Whatever your decision, using a word frequency list can alert you to editorial problems before you ever start editing, and it can help you achieve the editorial consistency you desire.

You can download WordCounter here:

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

_________________________________________

READERS WRITE

Judy Stein wrote:

Eric Fletcher writes, "What is particularly useful about this approach is that you can then later collect all of the flagged items in a single step--either for separate review or for use in a style guide. (This method only works for Word 10+.)"

What's Word 10+? I assume it's something beyond Word 2000, because he goes on to talk about a "Highlight all items found in" box--but I don't have one of those.

I replied:

Word 10 is the same as Word 2002 is the same as Word XP. "Word 10+" means Word 10 and anything higher, which is currently Word 11, comprising Word 2003 (PC) and Word 2004 (Mac). Back in the good old days, Word was numbered with, well, numbers rather than years. So we had Word 2, Word 5, and Word 6. With Word 95, however, Microsoft decided to get fancy, but a lot of folks still referred to it as Word 7. Word 97 (and 98) is thus Word 8, Word 2000 (and 2001) is Word 9, and so on.

Meg Cox wrote:

Thanks Eric Fletcher. That's some good stuff that I will wade through when I have the mental energy (it's very complicated!).

Meantime, I have solved my problem of viewing style sheet items in alphabetical order so I can spot near misses as I go along without having to scroll to the proper place each time to insert the new item. (I believe Eric's method would have this happening at the end of the chapter or project rather than all along.)

I also index books, so I have SKY indexing software. I knew this software would solve my problem, but I was stuck because every time I tried to shrink its window so I could tuck it in a corner of my screen, I would get an error message. Well, I decided to just shrink the window bit by bit, ignoring the recurring, and, as it turns out, benign, error message, until I had a nice compact little window to stick in the corner. Now the windows are sharing space nicely.

Now I can type or paste new entries in and immediately see them in context alphabetically next to other entries of the same category--personal name, foreign term, whatever. If I'm typing instead of pasting, autocomplete will let me know right away that the term has been encountered already (perhaps in a previous file if I'm using the color-coding method).

Now I'm wondering: I don't think a Word macro can open a window in another program and order a paste there. That would be very helpful.

If you know of a solution for Meg, please sent it to hints [at symbol] editorium.com.

Pat LaCosse wrote:

As an editor I use VBA to script and extend Word nearly every day. I'm delighted to have found your newsletter.

In "Numbers by Chicago, Part 2" [June 9, 2004], you provided a link to two scripts one might use to eliminate duplicates in a list. Although I'm not too familiar with WordBasic commands, I noticed that your examples were able to handle only duplicates that are adjacent to one another in the list. No problem if you've sorted the list, but what if sorting the list is not necessary or desirable? (There are times, for example, when preserving the order of occurrence is desirable.)

I thought I'd share a technique I've grown to prefer, which eliminates duplicates no matter where they are found in the list. It utilizes VB's dictionary object and it is fast. I've run scripts similar to the one below on files that are 11 MB big, and the difference in speed as a result of using the dictionary object (as opposed to recursively iterating through each paragraph) is remarkable. The dictionary object's comparemode property provides a convenient way for the filtering to be case sensitive if need be. One can read more about the dictionary object's properties and methods in Word's VBA help file. I should mention that I've used the dictionary object only on Windows machines running Word 2000 and 2002. I don't know how available the dictionary object is for other platforms and versions, but those who have access to it will find it quite useful for a variety situations. I use it to create concordances, audit documents for special characters, etc. all the time.

Here is an example with comments. Normally I try to be much more modular in my programming. For example, I would usually put the core functionality here into a sub or function to which I could pass a range object (allowing me to pass it the range of an entire document or merely that of a selection within a document). And I'd make the comparemode an optional argument to pass. Because the purpose here is simply to show the dictionary object in action, I've adapted some code to be a situation-specific script, which allows it to be tested easily on a document. With that disclaimer, here it is:


Sub ListEliminateDuplicates()
'Pat LaCosse
'Adapted from my ConcordanceTools template
'and submitted to the Editorium newsletter
'on June 17, 2004.
Dim para As Paragraph
Dim dict
'Create an instance of the dictionary object
Set dict = CreateObject("Scripting.Dictionary")
'Set comparemode; use vbBinaryCompare
'for case-sensitive filtering
dict.comparemode = vbTextCompare
'Iterate through all the paragraphs in the doc.
For Each para In ActiveDocument.Paragraphs
'If we've already encountered this item,
'then delete the paragraph.
If dict.Exists(para.Range.Text) Then
para.Range.Delete
Else
'If we haven't already encountered this item,
'then add it to the dictionary's keys.
dict.Add para.Range.Text, ""
End If
Next para
Set dict = Nothing
MsgBox "Done!"
End Sub

If you don't know how to use such macros, you can find out here.

Linda DeVore and Leo Wong wrote to say that the lines in last week's DeleteDuplicates macro broke incorrectly in their email and so wouldn't run correctly. Here's a version in which the lines are shorter, which should solve the problem:


Sub MakeCordance()
'Courtesy of the Editorium
'http://www.editorium.com
'Mark an index entry for each word in the document:
Dim myWord
For Each myWord In ActiveDocument.Words
ActiveDocument.Indexes.MarkEntry _
Range:=Selection.Range, Entry:=myWord
Next myWord
'Go to the end of the document:
Selection.EndKey Unit:=wdStory
'Mark place with a bookmark:
ActiveDocument.Bookmarks.Add _
Range:=Selection.Range, Name:="IndexStartsHere"
'Generate an index based on the entries marked earlier:
With ActiveDocument
.Indexes.Add Range:=Selection.Range, _
HeadingSeparator:=wdHeadingSeparatorNone, _
Type:=wdIndexIndent, RightAlignPageNumbers:= _
False, NumberOfColumns:=1, _
IndexLanguage:=wdEnglishUS
.Indexes(1).TabLeader = wdTabLeaderDots
End With
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, _
Name:="IndexStartsHere"
'Select the index, from the bookmark
'to the end of the document:
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
'Turn the index "field" into actual text:
Selection.Fields.Unlink
'Get rid of the page numbers after the index entries:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ", [0-9]@[^013]"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, _
Name:="IndexStartsHere"
End Sub

Many thanks to Judy, Meg, Pat, Linda, and Leo for their excellent tips and comments.

_________________________________________

RESOURCES

If you want to get very serious about concordance software, you might want to look at the explanations and resources here:

http://www.uni-giessen.de/~ga1007/ComputerLab/concordance.htm

Making a Concordance

Have you ever needed to make a list of every word in a document? If so, here's a macro that will do it for you automatically. Basically, the macro marks an index entry for every word in your document, generates the index, and removes the page numbers, leaving you with an alphabetical list of words used (at the end of the document). It's sometimes interesting to see what Microsoft Word considers a "word"; periods, commas, and other unlikely items will be included.

To use the macro, open a document for which you need to make a concordance. (Be sure to keep a backup, just in case.) Then, run the following macro on the document (I've included comments to explain how it works):


Sub MakeConcordance()
'Courtesy of the Editorium
'http://www.editorium.com
'Mark an index entry for each word in the document:
Dim myWord
For Each myWord In ActiveDocument.Words
ActiveDocument.Indexes.MarkEntry Range:=Selection.Range, Entry:=myWord
Next myWord
'Go to the end of the document:
Selection.EndKey Unit:=wdStory
'Mark place with a bookmark:
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="IndexStartsHere"
'Generate an index based on the entries marked earlier:
With ActiveDocument
.Indexes.Add Range:=Selection.Range, HeadingSeparator:= _
wdHeadingSeparatorNone, Type:=wdIndexIndent, RightAlignPageNumbers:= _
False, NumberOfColumns:=1, IndexLanguage:=wdEnglishUS
.Indexes(1).TabLeader = wdTabLeaderDots
End With
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, Name:="IndexStartsHere"
'Select the index, from the bookmark to the end of the document:
Selection.EndKey Unit:=wdStory, Extend:=wdExtend
'Turn the index "field" into actual text:
Selection.Fields.Unlink
'Get rid of the page numbers after the index entries:
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = ", [0-9]@[^013]"
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
'Go back to the bookmark:
Selection.GoTo What:=wdGoToBookmark, Name:="IndexStartsHere"
End Sub

If you don't know how to use such macros, you can find out here.

If you want to keep the page numbers, just leave out these lines:

'Get rid of the page numbers after the index entries:

Selection.Find.ClearFormatting

Selection.Find.Replacement.ClearFormatting

With Selection.Find

.Text = ", [0-9]@[^013]"

.Replacement.Text = "^p"

.Forward = True

.Wrap = wdFindContinue

.Format = False

.MatchCase = False

.MatchWholeWord = False

.MatchAllWordForms = False

.MatchSoundsLike = False

.MatchWildcards = True

End With

Selection.Find.Execute Replace:=wdReplaceAll

For certain kinds of projects (catalogs, for example), you may be able to use a concordance to create an index of your document. You can learn more here:

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

Need to create a concordance for a whole bunch of documents at once? Use our MultiMacro program to run the macro above on all documents in a folder:

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

Or, you could use our WordCounter program, which now includes a concordance feature with a frequency count of the words in a document or documents. (This is a free upgrade for registered users.)

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

In other words, WordCounter can now tell you *how many times* each word has been used. How might that be useful for editing? Stay tuned. Over the next few weeks, I'll reveal all.

_________________________________________

READERS WRITE

Neman Syed wrote:

A colleague of mine recently asked me if there was a keyboard shortcut to modify styles (I love keyboard shortcuts 🙂 and I showed him how to assign shortcut keys to Word commands and deal with the Task Pane. Office XP has very poor native keyboard alternatives for the Task Pane, to the point I hardly ever use them, with just a couple of exceptions:

* F6 toggles between the document and the Task Pane. You can then use up/down/tab/shift-tab/enter/alt-down (to open drop-down lists), etc.

* CTRL-TAB cycles through the Task Pane, toolbars, and menu, when you're in one of the Task Pane, toolbars, or menu. If you're in the document, it puts a tab.

Realizing that making these shortcuts may be useful for others (and triggered by Pamela's observation in the 2004-05-12 broadcast that one person's obvious is another person's stunner 🙂 here's my method for solving "Joe's Problem": Assign the keyboard shortcut of ALT-M to the FormatStyleModify command.

Here's how:

1. Tools > Customize.

2. Commands > Keyboard.

3. From the Format category on the left, choose FormatStyleModify on the right.

4. Assign ALT-M or whatever keyboard shortcut you want in the "Press new shortcut key" box. If you choose something that already has an assignation, you'll see it noted in an unobtrusive manner below.

********************************

4a. If desired, change the template from Normal.dot to whatever document/template you want this to apply to. Obviously this selection influences what machines this keyboard shortcut is available on; in Windows 2000 and above, this may only be for the current user. In my case I keep all my modifications, macros, etc. in a file called custom.dot which I automatically throw into Word's Startup folder whenever I'm on a new machine. It's portable and powerful. Note: Only open documents and their templates are eligible candidates here, so to use my personal approach you'll need to manually open whatever startup template/add-in you use to store all your customizations.

********************************

5. OK your way back to your doc.

Your ALT-M shortcut now modifies whatever style your cursor is sitting in. (Not surprisingly, character takes precedence over paragraph.) It certainly saves me time and trouble, and I hope it will for your readers, too!

Many thanks to Neman for this terrific tip.

_________________________________________

RESOURCES

Not to toot my own horn, but I was recently looking through the back issues of this newsletter, available here:

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

Wow, there's an awful lot of good information there! If you didn't know about this archive, now you do. I hope you find it useful.

Numbers by Chicago, Part 2

Our previous article outlined a fairly lengthy Find and Replace routine to make sure inclusive (elided) numbers follow the style outlined in the Chicago Manual. Astute reader Andrew Lockton responded with a technique that is so important, it deserves a second article. Andrew suggested taking the "Find What Expression" wildcard, which takes the form 1, 2, and so on, and putting it not in the Replace With box, where it is ordinarily used, but in the *Find What* box--something I did not know was possible. Hats off to you, Andrew.

Instructions for using the "Find What Expression" wildcard can be found here:

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

Andrew's discovery opens up all kinds of possibilities for various problems I've previously been unable to solve, but let's look specifically at getting numbers by Chicago. The previous method required 18 separate searches. Andrew's brilliant methodology requires only three. Here's the explanation:

1. Numbers that take the form 104-105 need to be converted to 104-5:

Find What:

([1-9])0([1-9])-10([1-9])

Replace With:

102-3

What's going on there is that the first number grouping, ([1-9]), is being referred to by the 1 that follows the hyphen--in the Find What string. See it? Just before the 0 there? That tells Word to find (again) whatever was found by the first number grouping. For example, when the search hits something like "203-205," it says, "Hey, my first number group finds 2 [the first number in 203]. Let's see, is there also a 2 after the hyphen? Yes, there is!" Slicker than snake shoes, as expert word whacker Hilary Powers is fond of saying.

2. Numbers that take the form 104-110 need to be converted to 104-10:

Find What:

([1-9])0([1-9])-1([1-9])([0-9])

Replace With:

102-34

3. Numbers that take the form 111-112 or 119-120 need to be converted to 111-12 or 119-20:

Find What:

([1-9])([1-9])([0-9])-1([1-9])([0-9])

Replace With:

123-45

At first I thought it might be possible to combine 2 and 3:

([1-9])([0-9])([0-9])-1([1-9])([0-9])

But that would also find even hundreds (100, 200), which need to be ignored (100-114 rather than 100-14).

Many thanks to Andrew for the terrific tip.

_________________________________________

READERS WRITE

Alan Seiden wrote:

Here's another caps lock fixer. The program is called AntiCapsLock. It is free to try, but costs $10 to have the program remember one's settings.

http://www.orionsoft.cz/anticapslock.asp

We've set it up so that caps lock only toggles on or off when SHIFT is pressed along with the CAPS LOCK key. It works very well for a fussy computer user.

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

After reading the article "Numbers by Chicago," Jeanne Pinault wrote:

What I do with elided numbers is just replace all the hyphens with en dashes and then fix whatever comes up wrong when I edit the notes. That's because every set of endnotes I see is wrong in a slightly different way from every other set of endnotes I ever saw, so I have to read every character anyway. I can see that your marvelous find and replace would be a godsend with consistently formatted and voluminous endnotes produced on a regular basis, though. Are en dashes in there someplace?

I responded:

In the Find string, use ^150 (the en-dash code) instead of the hyphen.

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

Margaret Berson wrote:

I just was looking at your sequential replacement operation for page numbers. Why would you not use a macro that would go through and use the string position functions to evaluate the first digit of the first page number against the first digit of the second page number, deleting the unneeded first digit of the second number if it's the same, and leaving it alone if it's higher?

Wordmeister Steve Hudson sent in a macro that takes things even further. He wrote:

The following solution was designed to not just satisfy the English world with its 0-9 numerics. Use it to reduce hexadecimal addresses, Japanese, or anything. Even if the numbers aren't sequential, like hex, we just use ranges for the find such as "0-9A-F".

It is as simple as possible whilst being as generic as possible. Simpler solutions cannot work for non-English solutions as we cannot guarantee ASCII status. It is fully commented and written for clarity and education rather than speed. It will still run like greased lightning but 🙂


Public Sub NumberCruncher()
'Link this one to your toolbar
'Change any parms as needed from here
NumberCrunch ActiveDocument.Content
End Sub
Public Function NumberCrunch( _
Scope As Range, _
Optional NumberSeparator As String = "-", _
Optional Numbers As String = "0-9" _
) As String
'Another document solution from WordHeretic.com
'Produces short form number ranges anywhere in the provided
'document range. Eg 309-310 into 309-10 and 307-308 into 307-8
'You can use Unicode nnnn by using "^nnnn"
'NumberRange and architecture is for true I18N
'Known Issues: n-n will end up being n-. Eg 300-300 to 300-
'___________________
'Declare
'___________________
Const EndOfWord As String = ">"
Dim NumberRange As Range
Dim FirstNumber As Range
Dim SecondNumber As Range
Dim Separator As Range
Dim AnyNumber As String
Dim LenFirst As Long
Dim LenSecond As Long
'___________________
'Initialise
'___________________
Set NumberRange = Scope.Duplicate
Set FirstNumber = Scope.Duplicate
Set SecondNumber = Scope.Duplicate
'___________________
'Clarity
'___________________
AnyNumber = "[" & Numbers & "]@"
With NumberRange.Find
.Text = AnyNumber & NumberSeparator & AnyNumber & EndOfWord
.MatchWildcards = True
End With
'___________________
'Main program loop
'___________________
While NumberRange.Find.Execute(Replace:=wdReplaceNone)
Set Separator = NumberRange.Duplicate
With Separator.Find
.Text = NumberSeparator
.Execute(Replace:=wdReplaceNone)
End With
'So now we have the entire number range AND
'the separator range, we can calc the numbers
FirstNumber.Start = NumberRange.Start
FirstNumber.End = Separator.Start
SecondNumber.Start = Separator.End
SecondNumber.End = NumberRange.End
'Counting chars is NOT the same as an offset
LenFirst = FirstNumber.Characters.Count
LenSecond = SecondNumber.Characters.Count
'Now lets work out what's the same
'First up, if the second number is shorter than
'the first, it's already been done or is irrelevant.
'Eg 200-7
'If the second number is longer we cannot find common ground
'Eg 97-101
'Thus, we can ONLY operate on equal length numbers.
'Then, test for the number being a dynamic field
'as we can't really change those
If LenFirst = LenSecond And NumberRange.Fields.Count = 0 Then
'Now we need to match every character or finish
'We will shrink our FirstNumber range as we go,
'and delete the secondnumber range as we go
'Char comparisons DO use unicode
While FirstNumber.Characters(1) = SecondNumber.Characters(1)
FirstNumber.MoveStart
SecondNumber.Characters(1).Delete
Wend
End If
Wend
'___________________
'Destroy all objects
'___________________
Set FirstNumber = Nothing
Set SecondNumber = Nothing
Set Separator = Nothing
Set NumberRange = Nothing
End Function
Steve later added:
We may also want to include something like this if the user wants to run the macro on a range of text:
Public Sub NumberCruncherSelection()
NumberCrunch Selection.Range
End Sub

If you don't know how to use macros like that one, you can find out here:

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

The consistently brilliant Eric Fletcher wrote:

I was interested to see the tip from Meg Cox and Joy Freeman in the last Editorium posting about highlighting all instances of an item. In a job some time ago, some very foreign names were being used throughout. I knew they would cause problems later in the spell check but unless I was careful, a slightly different spelling of the same name would easily slip past. For example, "Mkandawire" might also be "Mkandewire"... I wanted to avoid the tedium of clicking the Ignore button during spell check but still have a way to check the items.

So, in order to both flag a word as already seen and turn off proofing, I created the little macro below. To use it, I select the word (or words) and click the button associated with it. All identical instances (note the MatchCase) are set in green color with no proofing. The resultant green color shows that the word has already been encountered (as noted in your reader's tip).

However, what is particularly useful about this approach is that you can then later collect all of the flagged items in a single step -- either for separate review or for use in a style guide. (This method only works for Word 10+.)

1. In the Find box, leave Find What empty but use Format to select the color (Green in my case).

2. Click the "Highlight all items found in:" box and choose Main Document. The Find button changes to Find All, and when you click it, all instances of the color green will be highlighted.

3. Now for the fun part: close the F&R dialog and choose Copy (Ctrl-C); open a new document and paste (Ctrl-V).

What you get is a list with each found item on a line of its own. You can then sort it and more easily review the list since all identical instances of the same item sort together. (...and I'm sure someone out there will even have a VBA script that could eliminate all duplicates in the sorted list!)

[Editor's note: You'll find such a script here: http://lists.topica.com/lists/editorium/read/message.html?mid=1702467672]

Here's my macro:


Sub FlagThis()
' FlagThis Macro
' Flags current selection as green with no proofing throughout the
document. E Fletcher 2003-10-23
'
Dim flagit As String
flagit = Selection
Selection.MoveLeft Unit:=wdCharacter, Count:=1
With ActiveDocument.Content.Find
.ClearFormatting
.Text = flagit
.MatchCase = True
With .Replacement
.Text = "^&"
.ClearFormatting
'-- colour and no proofing options for replace
.Font.Color = wdColorGreen
.NoProofing = True
End With
.Execute Format:=True, Replace:=wdReplaceAll
End With
Selection.MoveRight Unit:=wdWord, Count:=1
End Sub

Note that I have it set up so the cursor ends up at the end of the first word in the selection. If users want to just add color and not set the proofing off, the ".NoProofing = True" statement should be removed.

I also use a slightly modified version of this method to flag words set in a different language. My Quebec flag button sets the selection in my custom "French" character style [French (Canada) language and font color blue] so I modified the FlagThis macro to set all instances of the selection to the French style. The spell check switches languages on the fly so it checks properly in multiple languages. Then, before I print or release the final version of the file, I modify the style definition(s) to change the language color(s) to automatic.

Many thanks to Alan, Jeanne, Margaret, Steve, and Eric for their terric tips and comments.

Numbers by Chicago

I recently worked on a manuscript with lots of source citations, many of which had page numbers formatted like this:

122-123

I prefer the shorter style recommended in the Chicago Manual of Style (8.69):

122-23

And besides, the manuscript was inconsistent, sometimes using one style, sometimes the other. Not wanting to fix all of these by hand, I decided to put the old wildcard search to work. You can learn about searching with wildcards in my free paper "Advanced Find and Replace in Microsoft Word":

http://www.editorium.com/ftp/advancedfind.zip

The first thing I needed to do was simplify things. Consider the style for even hundreds:

100-109

100-119

100-201

In all such cases, the numbers were already in the correct style, so I decided to just get them out of the way, like this:

Find What:

00-

Replace With:

~~-

(Those tildes are just arbitrary placeholders to be turned back to zeroes later.)

With that taken care of, I originally thought I could change all the other numbers like this:

Find What:

([0-9]{3}-)[0-9]([0-9]{2})

Replace With:

12

That "Find What" string finds any set of three {3} numbers [0-9] followed by a hyphen, followed by a single number [0-9], followed by any set of two {2} numbers [0-9]. The items in parentheses are treated as as a group.

The "Replace With" string replaces the first 1 parenthetical group with itself and the second 2 parenthetical group with itself, leaving out any number [0-9] that was not grouped in parentheses.

That will definitely change 122-123 to 122-23, but it will also change 308-309 to 308-09, so we'll need to get a little fancier. How about this?

Find What:

([0-9]{3}-)[0-9]([1-9]{2})

Replace With:

12

Notice that I've changed that last number range to [1-9] rather than [0-9]. That means numbers like 308-309 will not be found but numbers like 308-319 will. (Come to think of it, that single number in the middle could probably be [1-9] as well, since there shouldn't be any page numbers like 308-019. Of course, you never know.) Now, does that solve the problem?

Well, no. We still need to deal with numbers like this:

398-415

We certainly don't want that changing to 398-15. And what about this?

247-517

Unlikely, I'll admit, but still possible.

And that means we can't do our find and replace all in one shot. Instead, we'll have to do 18 specific searches:

(1[0-9]{2}-)1([1-9][0-9])

(2[0-9]{2}-)2([1-9][0-9])

(3[0-9]{2}-)3([1-9][0-9])

(4[0-9]{2}-)4([1-9][0-9])

(5[0-9]{2}-)5([1-9][0-9])

(6[0-9]{2}-)6([1-9][0-9])

(7[0-9]{2}-)7([1-9][0-9])

(8[0-9]{2}-)8([1-9][0-9])

(9[0-9]{2}-)9([1-9][0-9])

(10[1-9]-)10([1-9])

(20[1-9]-)20([1-9])

(30[1-9]-)30([1-9])

(40[1-9]-)40([1-9])

(50[1-9]-)50([1-9])

(60[1-9]-)60([1-9])

(70[1-9]-)70([1-9])

(80[1-9]-)80([1-9])

(90[1-9]-)90([1-9])

At least that's how it looks to me. If you have a better way, I'd love to hear about it.

You can do the searches by hand if you like. You've got 20 chapters, all in separate files? Let's see--20 x 18 = 360 separate searches. Ouch! Of course, you could use my MegaReplacer program to do them all at once, freeing up your time for something more interesting:

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

Don't forget, we still need to turn those tildes back into zeroes:

Find What:

~~

Replace With:

00

Now all of those page numbers should be in Chicago style. How beautiful!

"What about four-digit numbers?" you ask. I leave it as an exercise for you to work out.

If you'd like this whole thing ready to run in MegaReplacer, here it is:

00-|~~-

(1[0-9]{2}-)1([1-9][0-9])|12+m

(2[0-9]{2}-)2([1-9][0-9])|12+m

(3[0-9]{2}-)3([1-9][0-9])|12+m

(4[0-9]{2}-)4([1-9][0-9])|12+m

(5[0-9]{2}-)5([1-9][0-9])|12+m

(6[0-9]{2}-)6([1-9][0-9])|12+m

(7[0-9]{2}-)7([1-9][0-9])|12+m

(8[0-9]{2}-)8([1-9][0-9])|12+m

(9[0-9]{2}-)9([1-9][0-9])|12+m

(10[1-9]-)10([1-9])|12+m

(20[1-9]-)20([1-9])|12+m

(30[1-9]-)30([1-9])|12+m

(40[1-9]-)40([1-9])|12+m

(50[1-9]-)50([1-9])|12+m

(60[1-9]-)60([1-9])|12+m

(70[1-9]-)70([1-9])|12+m

(80[1-9]-)80([1-9])|12+m

(90[1-9]-)90([1-9])|12+m

~~|00

_________________________________________

READERS WRITE

Mary Russell wrote:

I'm working on a revision of an encyclopedia on world religions that already has a 108-page word list and a 1,000-page index of terms I need to check *everything* against. I'm using your style sheet macro to slap each term I want to check into the style sheet as I go and then doing a separate pass to check them all--and having them alphabetized saves me a lot of scrolling around in those files. By the way, I *love* your macro. I run the style sheet minimized and don't even have to switch back to my original document. You should really be selling this one. I'm usually more restrained, but this really is a great idea.

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

Meg Cox wrote:

Joy Freeman on Freelance suggested a new approach that I think will alleviate the style sheet challenge considerably. I haven't tried it yet, but I'm going to on the next chapter I start. She gave her permission to repeat the approach here:

With each occurrence of a new name, search for the same and replace it with itself in a different color (say, blue). Then you know you've already encountered it and don't need to check it against the style sheet. That way you only have to take action with variations and first occurrences. If it's blue, move on through!

I suspect this approach will come in very handy the next time I have a manuscript with hundreds of unfamiliar personal, place, and organizational names, and it will help in simpler projects as well.

Another way it will help: Sometimes in a long chapter it's hard to remember whether the full name of a person or organization has appeared yet (my clients routinely ask for full version on first occurrence in each chapter, then shortened version thereafter). If the changing to blue is done chapter by chapter (and I think it could be handled quickly--I need to think macro on this), blue will mean the full version has already occurred and an abbreviation or last-name-only may be called for. Could be useful for long sets of notes too so I know when it's time to go with a short citation! (Lately I'm seeing plenty of chapters with 70 or more notes.) Oh, and good for parenthetical citations too, so I know what I've already checked against bibliography.

[Editor's note: Our RazzmaTag program would be very useful for this kind of thing: http://www.editorium.com/razzmatag.htm.]

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

Brad Hurley wrote:

Steve Hudson wrote:

I'd like to advise you and your readers to avoid Outlook

2003. It has more bugs than the NSW locust plague here in

Australia at the moment. I could fill an article with simple

features that cause immediate failures.

This is almost the opposite of my experience. I've been using Outlook 2003 daily on my Windows 2000 machine since last October, and it has never crashed. I have encountered several bugs and design flaws, but overall my experience has been positive. The much-improved spam filtering and the new three-pane design make it a far better program than previous versions. The upgrade from Outlook 2000 went flawlessly and it handles my large e-mail archive files (300-600 megabytes each) without a complaint. The only serious problems I've noticed so far are:

1. Editing a message in your outbox makes it impossible to send; you have to transfer it to a different folder and send it from there.

2. E-mail address auto-complete doesn't work if your contact's address book entry also has a fax number listed (this is a very frustrating flaw because Outlook should be smart enough to know you're not trying to send a fax when you've composed an e-mail message to someone).

3. Hitting the return button to start a search only works once a session; after that you have to use your mouse to click the "find now" button.

Other than that, I'm satisfied with Outlook 2003; in fact it's the only element in the Office suite that I've found worth upgrading from the 2000 versions.

Many thanks to Mary, Meg, and Brad for their helpful tips and comments.

_________________________________________

RESOURCES

Bruce Koehler wrote:

Another approach to handling accidental press of the Insert key and other keys (e.g. Caps Lock) is a small freeware program called FirstCap. It allows you to set up these potentially problematic keys in various ways such as:

* Disable

* Disable--but with a work-around to re-enable once or continuously sound an alert when pressed

Terrific little program. Just Google search on "FirstCap" for many sites that offer it.

And while I'm at it, here are a few more that would be useful to Word users:

Memokeys: "MemoKeys can help you to fill forms faster, to execute repetitive tasks without having to type every time the same text or keystrokes. The principle is simple: MemoKeys creates associations between key combinations on your keyboard and some predetermined texts or system actions . . . " Uses a Function key (F12, for example) plus an alphanumeric key. Works in all programs.

MinMax extender: adds icons by the "-" and "X" icons at the upper right of a window to allow rollup, expand window to full screen width or height (and undo), etc.

FileEx (shareware--not free): can expand most dialog boxes--a great help in Word--also allows a different default Save destination (great when you're opening a lot of files in one folder but want to save them to another location).

Many thanks to Bruce for suggesting these programs. Bruce also suggested asking newsletter readers if they know of other editing or Word-related shareware and freeware. If you do, please let us know, and we'll list them in the next newsletter: mailto:resources [at symbol] editorium.com

Fixing Typos Automatically

All this talk about editorial style sheets in the past couple of newsletters got me thinking again about lists of automatic corrections. Long ago, I wrote about this and provided a couple of such lists:

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

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

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

I now realize, however, that those lists don't include nearly as many typographical errors as they could. I'm talking about errors like these:

abbout (about)

yeild (yield)

yera (year)

yoiu (you)

yoiur (your)

So here, for your editorial pleasure, is a giant list (more than 1,200 entries) compiled from various typo and AutoCorrect collections:

http://www.editorium.com/ftp/typolist.zip

The list is currently set up for use with our MegaReplacer program, with entries like this:

abbout|about+w

yeild|yield+w

yera|year+w

yoiu|you+w

yoiur|your+w

Words before the pipe symbol (|) contain the typos. Words after the pipe symbol are their replacements. And the +w at the end of each entry tells Word to search for "Whole words only." MegaReplacer will run such a list on the active document, all open documents, or all documents in a folder, fixing all of the typos in one fell swoop.

Of course, Word's spell checker will also catch these typos--if you want to click, click, click through them all manually. But why not put MegaReplacer to work while you do something more worthwhile? Of course, running that giant list on a bunch of documents could take a while, so you might want to (1) pare down the list to include only those entries you think you'll really need and (2) run it on fewer documents at a time. You can learn more about MegaReplacer here:

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

You might also want to use some of these entries (minus the pipe symbols and +w's) in your AutoCorrect list (some of them are probably already there). Feel free!

_

FROM WORD 2K TO 2003: WORD'S TASK PANES VBA REFERENCE

Wordmeister Steve Hudson sent his most recent article in his series about Word 2003--a sneak preview especially for Editorium Update readers before the article is published elsewhere. The article covers one of Word's most important features, the Task Pane, with an emphasis on VBA, and Steve covers the topic in almost unbelievable detail. If you want the real scoop, look no further. You can download Steve's article by clicking here:

http://www.editorium.com/ftp/taskpane.zip

Steve also wrote:

I'd like to advise you and your readers to avoid Outlook 2003. It has more bugs than the NSW locust plague here in Australia at the moment. I could fill an article with simple features that cause immediate failures.

If you are happy to live with plain text emails, you get fewer problems. Not none, fewer. Rules are broken, insofar as there are several options that crash Outlook when you select them. Contacts has a few problems that sporadically cause crashes; even picking names from your address book goes belly up regularly. 🙁 No Service Packs as of yet.

I'm putting up with it, as the rest of Office 2003 is very nice.

Many thanks to Steve for doing intense research on Office 2003 and making it available for our use.

_________________________________________

READERS WRITE

Andrew Savikas wrote:

Two quick tips came to mind while I was checking out your archives that might interest readers of your newsletter:

1. The primary motivation for most users when re-assigning the Insert key is to avoid accidental invocation of the cursed Overtype feature; adding a new function to the Insert key is just a bonus. To accomplish the former semi-permanently, just intercept the command:


Sub Overtype()
' Do nothing (or do something else)

End Sub

Then users can re-assign or un-assign the Insert key at will, without any fear of Overtype returning.

[For more information, see the past newsletters here:

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

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

2. Style aliases are indispensable but can cause problems when exporting to a different format. This macro removes them (Word 2000+ for Windows):


Sub RemoveStyleAliases()
Dim sty As Style
For Each sty In ActiveDocument.Styles
sty.NameLocal = Split(sty.NameLocal, ",")(0)
Next sty
End Sub

[For more information, see the past newsletter here:

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

If you don't know how to use such macros, you can find out here.

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

Meg Cox wrote:

Some editors don't like to alphabetize an editorial style sheet as they go along. For me, it's essential if the style sheet is to be usable--especially in a book with a million personal and place names, and especially if it's about an unfamiliar geographical region.

Without keeping the style sheet in alphabetical order, I'm not going to spot the close-but-not-quite situations. Case in point: in my style-sheet-nightmare project, the author was rendering the names every which way. Was it Leon Mba or Leon M'ba? With an accent on the e or not? Denis Sassou-Nguesso with or without the accent, with or without the hyphen? Sassou-Nguesso as surname only, or just Nguesso? Or Sassou Nguesso? Some names appeared infrequently enough that I never would have been able to remember whether they had come up before and how they had been rendered. (This 700-page manuscript covered politics in 14 francophone African countries over a period of 120 years.)

Even in easier projects, it's the alphabetization that enables me to spot the inconsistencies as I go along so I can change them all to the same thing. In the 14-countries project, it would have been no easy matter to go back and search and replace later because the versions of the names varied too widely, so I had to decide on the first occasion of each inconsistency. If the author wanted to go with a version different from what I had settled on, once they were all consistent I would have been able to do a global search and replace. (Thank goodness in this case cleanup was in-house!)

If I wasn't working in history and political science, this wouldn't be as much of an issue.

As it turned out, I didn't come up with a good way to do what I wanted to do. Maybe I could have with more fiddling, but I finally needed to just give up and keep moving through all the names.

Many thanks to Andrew and Meg for their helpful tips and comments.

_________________________________________

RESOURCES

The Design Science site has some marvelous advanced tutorials on Word's AutoCorrect feature:

http://www.dessci.com/en/support/tutorials/autocorrect/tutorial.htm

http://www.dessci.com/en/support/tutorials/autocorrect/advanced.htm

Restoring Superscript to Note Numbers

I get manuscripts with all kinds of weird formatting, but recently I got one from which all formatting had been removed. That might have been all right, but the note reference numbers were no longer superscript; they all looked something like this.42 I wasn't about to fix all those by hand, so I came up with this solution, which I hope you'll find as useful as I did:

1. Back up your documents, just in case.

2. Call up Word's Replace dialog (Edit > Replace).

3. In the "Find What" box, enter this (just copy and paste it from this article):

([! 0123456789,:$(])([0-9]{1,})

4. In the "Replace With" box, enter this:

12

5. Click the "More" button if it's available.

6. Put a check in the "Use wildcards" checkbox.

7. Click the "Replace All" button.

8. In the "Find What" box, enter this:

(*)

9. In the "Replace With" box, enter this (formatted as superscript):

1

10. Click the "Replace All" button.

All of your note numbers should now be in glorious superscript.

Want to know more about two-step finding and replacing?

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

Want to know more about wildcard searching?

http://www.editorium.com/ftp/advancedfind.zip

Want to know how to remove directly applied document formatting without removing superscript, italic, bold, and so on?

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

_________________________________________

READERS WRITE

After reading last week's newsletter with its editorial style sheet macros, Jim Pinkham wrote:

You can also overcome the limitation on having only two Word docs open to make Hilary's macro run by simply specifying the windows you wish to switch between in the macro. For example, here's a snippet from one of mine:

Selection.SelectRow

Selection.Cut

Windows("Blue Rows.doc").Activate

Selection.Paste

Windows("Weekly Improvement Analysis March 22-28.doc").Activate

When I use this macro, I'll create a new "Weekly Improvement Analysis" doc each time--so I simply edit the file name accordingly.

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

Pamela Angulo wrote:

As I read today's newsletter, 2004/05/05: Editorial Style Sheet Macro, I wondered why anyone editing and creating a style sheet on a computer would be concerned about pasting copied style terms by letter or in alphabetical order. (Organizing terms by type--names, places, scientific terminology, etc.--now, that I understand.)

I copy terms to my style sheet as I go, in the order they present themselves--more or less from top to bottom of the manuscript. For some jobs (e.g., chapters by multiple authors for the same book, or individual articles for inclusion in a single magazine issue), I keep track of chapter, article, or author for each term as well. But however I handle the initial list, I sort the terms alphabetically later, *not* while I'm copying and pasting (too much time, and too much brain!).

I create different versions of the style sheet for different purposes: A single comprehensive alphabetical list for a multiple-part project allows me and the proofreader to cross-check terms across the entire project, which is always helpful; several individual alphabetical lists sorted by chapter, article, or author allow me to send only the relevant list to each author for review.

With Table > Sort in Word, arranging my style sheet in alpha order is a no-brainer, and I like that after a long day at the helm. 🙂 BTW, some people don't realize that this command will work on *any* list; the list doesn't have to be in a table.

A while back, a copyeditor posted to Freelance asking how to convert her style sheet into a table so she could sort it. It struck me *hard* then that one person's "no duh!" (it's soooo obvious) is very often another person's "no way!" (never would have thought of that).

Many thanks to Jim and Pamela for their helpful tips and observations.

_________________________________________

RESOURCES

The EServer TCLibrary of editing articles has a wealth of information on all kinds of publishing topics. Wow, look at all this great stuff!

http://tc.eserver.org/dir/Articles/Editing