Deleting Extraneous Carriage Returns in Footnotes and Endnotes

During my editing career, I’ve often run into problems with footnotes and endnotes in Microsoft Word. Many authors have no clue about how notes are meant to work, and Microsoft certainly hasn’t made it obvious. In fact, they’ve made it easy to mess notes up beyond repair.

One mistake authors make is to insert extraneous carriage returns before or after a note. Why? Because they don’t like the positioning of the note on the page, which they’re trying to make “pretty,” not understanding the problems that will cause in editing and typesetting.

You can try to remove the extraneous returns like this:

1. Click View > Draft.
2. Click References > Show Notes.

Your cursor should now be in the Notes pane.

3. Click Home > Replace.
4. In the “Find What” box, enter two paragraph codes:

^p^p

5. In the “Replace With” box, enter one paragraph code:

^p

 6. Click the “Replace All” button.

Word will replace some of the double returns, but not all of them. And if you try to delete some of the remaining returns, you’ll get an error message:

“This is not a valid action for footnotes.”

What’s going on there is that not all carriage returns are created equal. Some of the returns are “special” note returns, and the only way to delete them is to delete the note itself back in the text.

The solution? A macro, of course. But a macro with a twist. As we’ve seen, you can’t just find double returns and replace them with a single return (even in a macro). And trying to delete extra returns results in an error. So let’s use that error!

Before running the macro, you must be in Draft view, with your cursor at the top of the Notes pane. (How to get there is explained above.)

In the macro, you’ll see a couple of “comments,” which are explanations or instructions intended for the person reading the code. Comments are preceded by a single quotation mark, which tells the macro to ignore the rest of the text on that line. They are usually displayed in green. For example, the first comment in the macro reads:

'To clean returns in endnotes rather than footnotes,
'change "Footnotes" to "Endnotes" in the following line:

And now, here’s the macro:

Sub CleanReturnsInNotes()
'To clean returns in endnotes rather than footnotes,
'change "Footnotes" to "Endnotes" in the following line:
NoteCount = ActiveDocument.Footnotes.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
  .Text = "^p^p"
  .Replacement.Text = ""
  .Forward = True
  .Wrap = wdFindContinue
  .Format = False
  .MatchCase = False
  .MatchWholeWord = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = False
End With
Selection.Find.Execute
On Error GoTo TrapTheError
While Selection.Find.Found
  Selection.MoveLeft
  'The following line may trigger an error!
  Selection.Delete
  Selection.Find.Execute
Wend
GoTo TheEnd
TrapTheError:
ErrorCount = ErrorCount + 1
Selection.MoveRight
Selection.Delete
If ErrorCount < NoteCount Then Resume Next
TheEnd:
End Sub

Let’s look at some of those lines.

NoteCount = ActiveDocument.Footnotes.Count

NoteCount is a variable; that is, it’s a container that can hold a numerical value—in this case, the number of footnotes in the document. We get that value with the VBA command ActiveDocument.Footnotes.Count.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Just to be safe, these lines clear any formatting that might already be applied to the “Find What” and “Replace With” boxes in Word’s find and replace feature.

The following lines, from

With Selection.Find

down to

Selection.Find.Execute

simply find any instances of double paragraph returns. The replacement text is set to nothing, as we’re not trying to replace those returns with anything:

.Replacement.Text = ""

Instead, we’re going to try to delete the second return, which (unless the notes are really messed up) is a regular return rather than a special note return:

Selection.MoveRight
Selection.Delete

If it’s a special note return, then trying to delete it will cause an error, and the macro will execute this line—

On Error GoTo TrapTheError

—which sends the macro to this line:

TrapTheError:

Here’s what happens next:

ErrorCount = ErrorCount + 1

Using the variable ErrorCount, we count the number of errors, adding 1 each time we find one. (ErrorCount is initially empty, or zero.)

Selection.MoveRight
Selection.Delete

We move right and delete the next return.

If ErrorCount < NoteCount Then Resume Next

If the number of errors is less than the number of notes, we’re not through yet, as one of the remaining notes may still have a bad return next to it. So, we tell the macro to Resume operation at the next command after the error occurred. That command is:

Selection.Find.Execute

In other words, Word looks for the next occurrence of a double return. And this construction—

While Selection.Find.Found
Selection.MoveLeft
  'The following line may trigger an error!
  Selection.Delete
  Selection.Find.Execute
Wend

—ensures that it will keep looking as long as (While) double returns are found. (“Wend” is short for “While End”—it marks the end of the While construction.)

GoTo TheEnd

When no more double returns are found, this line is executed. It exists simply to avoid executing the error trap (TrapTheError: and the following lines) after the macro is finished, at which point

TheEnd:

marks the end of the whole operation.

I hope this explanation has helped you understand better how macros work, and in particular how you can actually use Word errors to force Word to do what you want it to do—something that gives me great pleasure.

Even if you don’t understand everything that’s going on in this macro, you can still use it to clean up extraneous returns in notes—something that should make your editorial life a little bit easier.

How to Add the Macro to Word and to the QAT (Quick Access Toolbar)

Here’s how to put this macro (or any other) into Microsoft Word so it will be available when you need it:

  1. Copy the text of the macro, starting with the first “Sub” and ending with the last “Sub.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “CleanReturnsInNotes.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor at the beginning of the document.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Click the name of your macro to select it.
  5. Click the “Run” button. (If you wanted to delete the macro, you could press the “Delete” button instead.)

Here’s how to put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Programs from the Editorium

Have you checked out the Editorium's latest Microsoft Word add-ins to help with your work?

IndexLinker creates hyperlinks from index page numbers back to the text to which they refer. If you're creating ebooks or PDFs with indexes, you need this program.

BookMaker automates typesetting and page layout in Microsoft Word. Stop fighting with page breaks, headers, and footers. Let BookMaker do the heavy lifting.

LyXConverter converts Word documents into LyX documents.

And, of course, many other useful add-ins are available as well.

A Special Deal: Editor's Toolkit Ultimate!

Editor's ToolKit Ultimate combines three great products:

The three products work together to create a powerful editing package to take you through three separate stages of copyediting.

Lyonizing Word: Removing Spaces at the End of Table Cells

Removing Spaces at the End of Table Cells

by Jack Lyon

Authors do funny things. Sometimes these things are inadvertent; sometimes they’re the result of trying to “prettify” documents for publication. In either case, editors have to clean up what the authors have done.

One such problem is spaces at the ends of table cells. A table cell should end with the text it contains. If there are spaces after that text, they can cause alignment (and other) problems if they’re allowed to persist into typesetting.

It should be a simple matter to clean up the extraneous spaces: Search for a space followed by an end-of-cell marker and replace with just an end-of-cell marker. But what magic code can we use to find or replace an end-of-cell marker? As it turns out, there isn’t one. But we can still get rid of those spaces with a macro. Here it is, with comments about what’s going on (text following a single quotation mark is a “comment”, which is also in green for clarity):

The Macro

Sub CleanCellEndSpaces()

'Define variables (that is, containers for information)
Dim aTable As Table
Dim aCell As Cell
Dim aRow As Row
Dim aColumn As Column
Dim aRange As Range 'That is, a specific area of the document
Dim aLen As Integer 'That is, a number
Dim LastChar As String 'That is, a string of characters (text)

Dim Tracking As Boolean 'True or False
Tracking = ActiveDocument.TrackRevisions 'Get setting of revision tracking
ActiveDocument.TrackRevisions = False 'Turn off revision tracking

On Error Resume Next 'In case of tables with "vertically merged" cells
'Cycle through tables, rows, and cells

For Each aTable In ActiveDocument.Tables
For Each aRow In aTable.Rows
For Each aCell In aRow.Cells

CheckAgain:

Set aRange = aCell.Range 'Set aRange variable to the contents of the current cell
aRange.End = aRange.End - 1 'Don't include the end-of-cell marker
aLen = Len(aRange.Text) 'Get the length of the cell's text
aString = aRange.Text 'Assign the text to a variable
LastChar = Right(aString, 1) 'Get the last character of the text
If LastChar = " " Then 'If the last character is a space

aRange.Text = Left(aRange.Text, aLen - 1) 'Set the text to be itself minus the trailing space
GoTo CheckAgain 'Go back and check for another space (there may be several)

End If
Next aCell
Next aRow
Next aTable

ActiveDocument.TrackRevisions = Tracking 'Set revision tracking back to its original state

End Sub

The Explanation

Here’s how the macro works.

We start by “dimensioning” (defining) our variables, like this:

Dim aTable As Table

“aTable” is an arbitrary name; I just made it up. But that whole line tells Word that aTable will represent a table in our document. The other “Dim” statements follow suit, with “aCell” representing a table cell, “aRow” representing a table row, and so on.

These three lines deserve special attention:

Dim Tracking As Boolean
Tracking = ActiveDocument.TrackRevisions
ActiveDocument.TrackRevisions = False

Dimensioning the “Tracking” variable as Boolean tells Word that the variable will be either true or false; those are the only two values it can hold.

Next, we set “Tracking” to the value of ActiveDocument.TrackRevisions. If revision tracking is on, “Tracking” will be set to “True.” If revision tracking is off, “Tracking” will be set to “False.” We do that to remember the current setting for revision tracking, because the next line, “ActiveDocument.TrackRevisions = False” actually turns revision tracking off (we’ll reset it later). This is necessary because (1) tracking the deletion of those extraneous spaces isn’t needed, and (2) using revision tracking may send this macro into an endless loop as it keeps “finding” the character that it just deleted (but is still there as a tracked revision).

The next line —

On Error Resume Next

— needs to be there in case a table includes “merged” cells, which will cause an error when the macro runs. If that happens, the macro will skip to the next line, which means that tables with “merged” cells will be ignored. There may be a better way to deal with such tables, but I don’t know what it is.

After that line, things get really interesting:

For Each aTable In ActiveDocument.Tables

This tells Word to work on “Each” table in ActiveDocument.Tables. “What’s that?” you ask. Well, obviously “ActiveDocument” is the active document — the document that’s open in Word with our cursor moving around in it. (Other documents may be open but not active.) In the active document, there’s a collection of objects called “Tables” — which are, of course, the tables in the document.

And now, a brief digression: As far as macros are concerned, a Microsoft Word document is “simply” a collection of various objects, such as tables, headers, footers, footnotes, endnotes, paragraphs, words, and much, much more. All of these objects have certain “properties.” For example, a paragraph may have the property of FirstLineIndent set to “True” — in other words, its first line is indented. Objects can also contain other objects. For example, a table always contains at least one row and one column. So, in our macro, we have this:

For Each aRow In aTable.Rows

That tells Word to work on each row in the current table. Similarly, this —

For Each aCell In aRow.Cells

— tells Word to work on each cell in the current row.

Next, we’re going to set the range of text we want to use (that is, aRange) to be the current cell:

Set aRange = aCell.Range

Then we’ll reduce the end of that range by one character, so we don’t include the end-of-cell marker:

aRange.End = aRange.End - 1

And, using the Len command, we’ll find out the length (number of characters) included in the range’s text:

aLen = Len(aRange.Text)

Now let’s get that text by putting it into the variable called “aString”:

aString = aRange.Text

And we’ll use the Right command to find out the last character of the text string (that is, the first character on the right of the string):

LastChar = Right(aString, 1)

That looks a little complicated, but it’s actually fairly simple. Let’s say our text string is “Hi, Mom!” The “1” tells the Right command at which character to start counting (from the right of the string). In other words, LastChar is assigned the last character of the string, which in this case is an exclamation mark (“Hi, Mom!”).

But what if the last character is a space? That’s what we really we want to know. The next line will tell us if that’s the case:

If LastChar = " " Then

If the last character is a space, we need to get rid of it, which we can do like this:

aRange.Text = Left(aRange.Text, aLen - 1)

That line changes the text of our range to itself minus its last character (if the previous line identified its last character as a space). But what if there’s more than one space? We want to get rid of those spaces too! And that’s where the next line comes in:

GoTo CheckAgain

That sends the macro back to the “label” we’ve created at this line:

CheckAgain:

And the operation is repeated on the cell until no more spaces remain at the end of the cell.

All of the “Next” commands that follow repeat the whole operation for every cell in every row in every table of the active document. Powerful stuff!

Finally, the macro restores revision tracking to its original setting as stored in the “Tracking” variable:

ActiveDocument.TrackRevisions = Tracking

As they taught us in kindergarten, it’s good to clean up after yourself.

This article is a brief introduction to manipulating Word “objects” with macros. Future articles may explore more of those objects, along with their “properties” and “methods.” If that’s more than you want to know, you may still find the macros themselves to be useful.

How to Add Macro to Word & to the QAT

Here’s how to put this macro (or any other) into Microsoft Word so it will be available when you need it:

  1. Copy the text of the macro, starting with the first “Sub” and ending with the last “Sub.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “CleanCellEndSpaces.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor at the beginning of the document.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Click the name of your macro to select it.
  5. Click the “Run” button. (If you wanted to delete the macro, you could press the “Delete” button instead.)

Here’s how to put the macro on Word’s QAT (Quick Access Toolbar):

  1. Locate the QAT (it’s probably on the top left of your screen either above or below Word’s Ribbon interface).
  2. Right-click the QAT.
  3. Click “Customize Quick Access Toolbar.”
  4. Under “Choose commands from:” click the dropdown list and select “Macros.”
  5. Find and select your macro in the list on the left.
  6. Click the “Add” button to add it to the QAT.
  7. Click the “OK” button to finish.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: Deleting Extraneous Carriage Returns in Footnotes and Endnotes

Deleting Extraneous Carriage Returns
in Footnotes and Endnotes

by Jack Lyon

During my editing career, I've often run into problems with footnotes and endnotes in Microsoft Word. Many authors have no clue about how notes are meant to work, and Microsoft certainly hasn't made it obvious. In fact, they've made it easy to mess notes up beyond repair.

One mistake authors make is to insert extraneous carriage returns before or after a note. Why? Because they don't like the positioning of the note on the page, which they're trying to make "pretty," not understanding the problems that will cause in editing and typesetting.

You can try to remove the extraneous returns like this:

1. Click View > Draft.
2. Click References > Show Notes.

Your cursor should now be in the Notes pane.

3. Click Home > Replace.
4. In the "Find What" box, enter two paragraph codes:

^p^p

5. In the "Replace With" box, enter one paragraph code:

^p

 6. Click the "Replace All" button.

Word will replace some of the double returns, but not all of them. And if you try to delete some of the remaining returns, you'll get an error message:

"This is not a valid action for footnotes."

What's going on there is that not all carriage returns are created equal. Some of the returns are "special" note returns, and the only way to delete them is to delete the note itself back in the text.

The solution? A macro, of course. But a macro with a twist. As we've seen, the macro can't just find double returns and replace them with a single return. And trying to delete extra returns results in an error. So let's use that error!

Before running the macro, you must be in Draft view, with your cursor at the top of the Notes pane. (How to get there is explained above.)

In the macro, you'll see a couple of "comments," which are explanations or instructions intended for the person reading the code. Comments are preceded by a single quotation mark ('), which tells the macro to ignore the rest of the text on that line. For example, the first comment in the macro reads:

'To clean returns in endnotes rather than footnotes, change ".Footnotes" to ".Endnotes" in the following line:

And now, here's the macro:

Sub CleanReturnsInNotes()
'To clean returns in endnotes rather than footnotes, change ".Footnotes" to ".Endnotes" in the following line:
NoteCount = ActiveDocument.Footnotes.Count
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find

.Text = "^p^p"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False

End With
Selection.Find.Execute
On Error GoTo TrapTheError
While Selection.Find.Found

Selection.MoveLeft
'The following line may trigger an error!
Selection.Delete
Selection.Find.Execute

Wend
GoTo TheEnd
TrapTheError:

ErrorCount = ErrorCount + 1
Selection.MoveRight
Selection.Delete
If ErrorCount < NoteCount Then Resume Next

TheEnd:
End Sub

Let's look at some of those lines.

NoteCount = ActiveDocument.Footnotes.Count

NoteCount is a variable; that is, it's a container that can hold a numerical value—in this case, the number of footnotes in the document. We get that value with the VBA command ActiveDocument.Footnotes.Count.

Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting

Just to be safe, these lines clear any formatting that might already be applied to the "Find What" and "Replace With" boxes in Word's find and replace feature.

The following lines, from

With Selection.Find

down to

Selection.Find.Execute

simply find any instances of double paragraph returns. The replacement text is set to nothing, as we're not trying to replace those returns with anything:

 .Replacement.Text = ""

Instead, we're going to try to delete the second return, which (unless the notes are really messed up) is a regular return rather than a special note return:

 Selection.MoveRight
Selection.Delete

If it's a special note return, then trying to delete it will cause an error, and the macro will execute this line—

On Error GoTo TrapTheError

—which sends the macro to this line:

TrapTheError:

Here's what happens next:

ErrorCount = ErrorCount + 1

Using the variable ErrorCount, we count the number of errors, adding 1 each time we find one. (ErrorCount is initially empty, or zero.)

Selection.MoveRight
Selection.Delete

We move right and delete the next return.

 If ErrorCount < NoteCount Then Resume Next

If the number of errors is less than the number of notes, we're not through yet, as one of the remaining notes may still have a bad return next to it. So, we tell the macro to Resume operation at the next command after the error occurred. That command is:

Selection.Find.Execute

In other words, Word looks for the next occurrence of a double return. And this construction—

While Selection.Find.Found

Selection.MoveLeft
'The following line may trigger an error!
Selection.Delete
Selection.Find.Execute

Wend

—ensures that it will keep looking as long as (While) double returns are found. ("Wend" is short for "While End"—it marks the end of the While construction.)

GoTo TheEnd

When no more double returns are found, this line is executed. It exists simply to avoid executing the error trap (TrapTheError and the following lines) after the macro is finished, at which point

TheEnd:

marks the end of the whole operation.

I hope this explanation has helped you understand better how macros work, and in particular how you can actually use Word errors to force Word to do what you want it to do—something that gives me great pleasure.

Even if you don't understand everything that's going on in this macro, you can still use it to clean up extraneous returns in notes—something that should make your editorial life a little bit easier.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

Lyonizing Word: The Next Character Macro

Today’s column by Jack Lyon marks the first essay in a new monthly series, “Lyonizing Word.” In this series, Jack will discuss using Microsoft Word, especially macros, to best advantage during the editing process. Please welcome Jack as a new columnist for An American Editor.

______________

Lyonizing Word: The Next Character Macro

by Jack Lyon

Macros and mastering Microsoft Word are keys to success in the business of editing. One can be a great editor and not master either, but it is more difficult, if not near-impossible, to have a successful editing business if you aren’t master of the tools you use.

My plan is to help you master Word and Word macros. My hope is that you will learn from each of my columns and will take the lessons learned and build on them yourself — for example, by building more complex and more useful macros that fulfill a need in your editing business. Here’s my first installment, which I hope you’ll find useful.

The NextCharacter Macro

I often use character codes while finding and replacing in Microsoft Word. What’s a character code? Here are some common ones:

^09 is a tab
^13 is a carriage return
^32 is a space

Especially in a wildcard search, you may have to use such codes because Word’s wildcard search engine can’t handle certain characters and will give you an error message if you try to use them.

But what if you don’t know the code for the character you need? You can probably look it up online or in a computer book, but wouldn’t it be nice to have a macro that would tell you immediately? Just put your cursor in front of the character and run the macro to get the code number. Here’s a macro that will do just that:

Sub NextCharacter()
Dim NextChar As String
NextChar = Str(AscW(Selection))
MsgBox “The code for the next character is” & NextChar
End Sub

That’s pretty simple, but there’s still a lot going on. Let’s look at each line in the macro.

Sub NextCharacter()

Here we tell Word the name of the macro, which is a subroutine (Sub) named NextCharacter. You can use pretty much any name you like, as long as it doesn’t start with a number or include any spaces. And the parentheses at the end of the name? I’ll reserve that discussion for a future article.

Dim NextChar As String

I just made up the name NextChar but not the commands around it, all of which are part of VBA (Visual Basic for Applications), Microsoft’s programming language for Word and other programs in the Office suite. If you want to learn more about “Dim,” “As,” “String,” and other VBA commands, here’s a good place to start: Getting Started with VBA in Word 2010.

In this line, we’re “dimensioning” (Dim) a variable to hold a value (NextChar) that we’ll use later in the macro. A variable is just a placeholder that can hold a value, like X in your high-school algebra class. Dimensioning just tells Word what *kind* of value we’re using — in this case, a string of characters rather than, say an integer, which can only hold numbers.

NextChar = Str(AscW(Selection))

This assigns a value to the NextChar variable. What value? The one produced by this:

Str(AscW(Selection))

“Selection” is the character to the right of your cursor (in the Western world).

“AscW” tells Word to find the ASCII or Unicode value of that character.

“Str” turns that value into a string — that is, characters rather than a value. Why? So we can see those characters in the message box produced by the next line:

MsgBox “The code for the next character is” & NextChar

This displays a message box (MsgBox) that gives us the code for the next character (as stored in NextChar), preceded by the text “The code for the next character is” just to pretty things up.

End Sub

This line simply ends the macro, or subroutine.

Now, here’s how to put this macro (or any other) into Microsoft Word so it will be available when you need it:

  1. Copy the text of the macro, starting with the first “Sub” and ending with the last “Sub.”
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Type a name for the macro in the “Macro name” box — probably the name used after the first “Sub.” For this macro, that’s “NextCharacter.”
  5. Click the “Create” button.
  6. Delete the “Sub [macro name]” and “End Sub” lines that Word created in the macro window. The macro window should now be completely empty (unless you already have other macros in there).
  7. Paste the macro text at the current insertion point.
  8. Click “File,” then “Close and Return to Microsoft Word.”

To actually use the macro:

  1. Place your cursor directly in front of the character you want to identify.
  2. Click the “View” tab on Microsoft Word’s ribbon.
  3. Click the “Macros” button.
  4. Click the name of your macro to select it.
  5. Click the “Run” button. (If you wanted to delete the macro, you could press the “Delete” button instead.)

After the macro runs, a dialog box will appear with the numeric code for the character. To dismiss the dialog box, click OK.

Now that you know the code for the character after your cursor, you can use that code in Word’s Find dialog. Or you can insert it into your document. To do so, hold down the ALT key and enter the code on the numeric keypad. For example, the code for an uppercase A is 65. You could insert that character by holding down the ALT key and entering 65 on the numeric keypad. Of course, it’s a lot easier just to hold down SHIFT and hit the A key, but what if you need to enter something more esoteric? Microsoft provides a code chart here: ANSI Character Codes Chart.

That’s it! I hope you find the macro useful, and that my explanation here helps you understand a little more about how macros work.

Jack Lyon (editor@editorium.com) owns and operates the Editorium, which provides macros and information to help editors and publishers do mundane tasks quickly and efficiently. He is the author of Microsoft Word for Publishing Professionals and of Macro Cookbook for Microsoft Word. Both books will help you learn more about macros and how to use them.

The Law of Least Surprise

I wear many hats, but two of my favorites are my editing hat (really just a green-celluloid visor that protects my eyes from the glare of the lightbulb dangling overhead) and my programming hat (a rakish fedora with a feather on the side). I alternate between the two on any given day, but there's one guiding principle that both hats share—the law of least surprise.

The law of least surprise was formulated by computer nerds who wisely realized that "a programmer should try to think of the behavior that will least surprise someone who uses the program, rather than the behavior that is natural from knowing the inner workings of the program." For example, if I'm writing a document in a word processor, and I type "3rd" (meaning "third"), the "rd" should not magically be formatted as superscript. But that's the default setting in Microsoft Word, which frequently violates the law of least surprise, often in very big ways.

One of the most egregious violations occurred with the introduction of the Document Map in Word 97. The feature didn't work unless heading styles were applied to headings in the document text. If it couldn't find any headings, it created them, automatically formatting short lines that looked as though they might be headings.

Another bad one was the universally hated "Clippy," the animated paperclip also introduced in Word 97. (Is there a pattern here?) Clippy would pop up at the most inopportune times, "helpfully" saying things like "It looks as though you're writing a grocery list. Do you need milk?" In 2007 Smithsonian magazine called Clippy "one of the worst software design blunders in the annals of computing." In 2010 Time magazine listed it as one of the 50 worst inventions. Even at Microsoft, Clippy's internal code name was "TFC," which did not stand for "that friendly clip." Nevertheless, I enjoy some of the creative spoofs that Clippy inspired.

The law of least surprise isn't just for programmers, though. It also applies to editors, who should change an author's text as little as possible while still ensuring clarity (and, in some situations, conformity to house style). I've had bad experiences with inept but well-meaning proofreaders who made changes because something I wrote didn't follow the "rules" or because they had a "better" way to express something than I did, even though my way was perfectly clear. This reminds me of a story about Abraham Lincoln:

A Cabinet meeting was called to consider [the United States'] relations with England. . . . One after another of the Cabinet presented his views, and Mr. Seward read an elaborate diplomatic dispatch, which he had prepared.
Finally Mr. Lincoln read what he termed "a few brief remarks upon the subject,'' and asked the opinions of his auditors. They unanimously agreed that our side of the question needed no more argument than was contained in the President's "few brief remarks.''
Mr. Seward said he would be glad to adopt the remarks, and, giving them more of the phraseology usual in diplomatic circles, send them to Lord Palmerston, the British premier.
. . . The President, half wheeling in his seat, threw one leg over the chair-arm, and, holding the letter in his hand, said, "Seward, do you suppose Palmerston will understand our position from that letter, just as it is?"
"Certainly, Mr. President."
"Do you suppose the London Times will?"
"Certainly."
"Do you suppose the average Englishman of affairs will?"
"Certainly; it cannot be mistaken in England."
"Do you suppose that a hackman out on his box (pointing to the street) will understand it?"
"Very readily, Mr. President."
"Very well, Seward, I guess we'll let her slide just as she is."
And the letter did "slide," and settled the whole business in a manner that was effective. (Alexander K. McClure, Yarns and Stories of Abraham Lincoln [Salt Lake City: Waking Lion Press, 2013], 160-61.)

When editors make changes not to ensure clarity but to meet some arbitrary aspect of their own sensibilities, they're doing it wrong. As an editor, I try to keep that in mind. And as an author, I don't like surprises.

New Programs from the Editorium

Wearing my programmer's hat, I've been working hard all summer to create some new Microsoft Word add-ins to help with your work:

IndexLinker creates hyperlinks from index page numbers back to the text to which they refer. If you're creating ebooks or PDFs with indexes, you need this program.

BookMaker automates typesetting and page layout in Microsoft Word. Stop fighting with page breaks, headers, and footers. Let BookMaker do the heavy lifting.

LyXConverter converts Word documents into LyX documents.

A Special Deal: Editor's Toolkit Ultimate!

Editor's ToolKit Ultimate combines three great products:

The three products work together to create a powerful editing package to take you through three separate stages of copyediting.

Editing Documents in LaTeX

Do you ever have to edit a document written in LaTeX? There’s recently been some discussion on Copyediting-L about how to do this. I know of three methods.

Method 1: Work in raw LaTeX

LaTeX looks like this:

chapter[On the Origin and Design of Government]{On the Origin and Design of Government in General, with Concise
 Remarks on the English Constitution}
 Some writers have so confounded society with government, as to leave
 little or no distinction between them; whereas they are not only
 different, but have different origins. Society is produced by our
 wants, and government by our wickedness; the former promotes our
 happiness emph{positively} by uniting our affections, the latter
 emph{negatively} by restraining our vices. The one encourages
 intercourse, the other creates distinctions. The first is a patron, the
 last a punisher.

As you can see, formatting and document structure are implemented with codes. That's okay; just don't mess with the codes unless you know what you're doing. You can open a LaTeX document in any text editor and start editing. When you're finished, save the file and return it to the authors.

But what if your authors need to see your revisions? In that case, a text editor isn't going to work. But Microsoft Word has revision tracking . . .

Method 2: Edit in Microsoft Word

There are ways to turn a LaTeX file into a Word document, but that's probably not what your authors want. Nevertheless, you can still edit in Word, using revision tracking. Here's how:

  1. Open the LaTeX file (extension .tex) in Word.
  2. Save the file as a Word file (extension .doc or .docx).
  3. Turn on Track Changes.
  4. Edit the text, being careful not to change any of the LaTeX coding.
  5. Don't use any of Word's formatting features (paragraph styles, italic, bold, and so on), which will be lost when the document is changed back to a text file (which, later, it will be).
  6. Save the Word file and send it back to your authors, who should review the file in Word so they can accept or reject your changes.

After all of the changes have been either (1) accepted or (2) rejected (in other words, so that all tracked changes have been taken care of), the authors should do this:

  1. Save the file as a text file (extension .txt).
  2. Change the .txt extension to .tex.

At that point, they should be able to compile the LaTeX file as usual.

Method 3: Edit in LyX

LyX is a graphical user interface for LaTeX, with its own version of revision tracking. Here's the procedure:

  1. You (the editor) install LyX. Unless you're planning to use LyX for typesetting, you just need the simple installer rather than the bundled version.
  2. Import the authors' LaTeX file into LyX (File > Import > LaTeX).
  3. Do your editing in LyX, using its revision-tracking feature (Document > Change Tracking > Track Changes).
  4. Ask your authors to review your changes in LyX and accept or reject as needed.

At that point, your authors can (1) export the file as LaTeX (File > Export > LaTeX) or (2) process the file from within LyX. If you want to use this method, you should do some back-and-forth testing with your authors before starting work on an actual manuscript.

If you find that you like working in LyX (I do), you may sometimes need a way to convert a Word document into a LyX document, which is not an easy task—unless you use my new Microsoft Word add-in, LyXConverter. I do not, however, recommend trying to round-trip a document—that is, convert a Word document into LyX and then back into Word. Again, there are ways to do it (via OpenOffice.org Writer), but how reliable the final conversion might be is open to question.

How about you? Do you get manuscripts in formats other than Word? If so, how do you handle them? Please let me know!

The Little Man Who Wasn’t There

Last night I saw upon the stair
A little man who wasn’t there.
He wasn’t there again today;
Oh, how I wish he’d go away!
—Hughes Mearns
 

In a post on his blog “An American Editor,” Rich Adin posits that eBooks may be sounding the death knell for authorial greatness:

http://americaneditor.wordpress.com/2013/02/18/are-ebooks-the-death-knell-of-authorial-greatness/

Why? Because unlike printed books sitting on a shelf, eBooks are not immediately visible to our view; we have to go find them on our eReader, or search for them online. “Out of sight, out of mind,” as the saying goes.

I won’t repeat Rich’s arguments here; you should go read them for yourself. But I do believe that Rich is onto something important, and his post made me think about other things that are becoming invisible in this modern age.

Note References

A recent trend in book publishing is the use of “blind” notes—that is, notes that exist in the back of a book but have no indication in the text that they exist. The only way to see if a particular passage has an associated note is to turn to the back of the book and check. “Fascinating paragraph,” you think. “I wonder if there’s a note about this.” You turn back to the notes and look. “Nope.”

What if your cell phone worked that way? Suppose your phone gave no indication—no ringtone, no flashing light—that a call was coming in. The only way to know would be to pick up your phone periodically and listen. Does that seem like a good system?

Is an author’s text really so elegant that it should not be besmirched with superscript note references? Give readers a break; if there’s a note, give them some indication.

Well-Written Indexes

Professional indexers and seasoned readers know that a good index is an essential part of a good nonfiction book. Not only does it allow you to find particular passages, but it also gives you an overview of a book’s contents. Does the latest tome on Microsoft Word have anything new to say about macros? Check the index.

But some authors and publishers think that an index can be generated by a computer—just feed the computer a list of important terms, and it will mark those terms as index entries in the text. Generate the index, and off  you go! (Microsoft Word actually includes a feature that will do this; I don’t recommend it.)

Similarly, those who publish in electronic form often think that a program’s “search” feature is all that’s needed for readers to find what they’re looking for. But consider the old saying “The hand that rocks the cradle rules the world.” It refers to motherhood, of course, but if you look for “motherhood” in a computer-generated index or with an electronic search, “The hand that rocks the cradle” won’t show up. A good index is a form of writing; it requires the application of a human mind, which can see meanings where a computer sees only words. (This, by the way, is why grammar checkers don’t work.)

Functional User Interfaces

Some web designers think that how a web page looks is much more important than how it works. They’re wrong about that. Imagine a web page so “artfully” done, so minimal in its design, that it offers no indication of how users should navigate the site. You would actually have to move your cursor around the screen to see what areas might be “clickable.” That’s the extreme, of course, but there are sites that offer little more than that. Google “minimalist web page” and you’ll find some.

Several years ago I attended the product launch for a specialized search engine. The interface had an elaborately designed logo with the word “Search.” Below that was a box where users could enter the text they wanted to find. Wanting to demonstrate the simplicity of the new search engine, the CEO invited his wife to step onto the platform and search for something, implying that if she could use the program, anyone could. (Unfortunately, this also demonstrated his own stupidity and callousness, but that’s another story.)  His wife entered some text but then couldn’t find where to click to activate the search. There was no button, no menu, nothing. Finally the CEO grabbed the mouse and clicked on the logo to activate the search. After all, it did say “Search.” The problem was, it didn’t look like something to click; it looked like a logo. Further, it was above the text box; but things should always appear in the order of use: First enter your text, then click “Search”—which means that the Search button should have come below the text box, not above it.

Form should always follow function; how something looks should always be subordinate to how it works. A button should look like a button.

Not that there’s anything wrong with simplicity. As Albert Einstein once said, “Everything should be as simple as possible, but never simpler.” Those who are involved in any kind of communication—which means all of us—need to keep that in mind.

 

PDF-Xchange Viewer

In the publishing house where I used to work, we experimented with what I call "paperless proofreading." A previous newsletter explains the concept:

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

We also talked about having proofreaders work from PDF files, but that would mean they'd need to get the full-fledged Adobe Acrobat software so they could annotate the text, pointing out errors for the typesetter to correct and inserting queries for the editor. Acrobat has some wonderful features, but at $299 it's a tad expensive for many proofreaders:

http://www.adobe.com/products/acrobatpro/acrobatstd.html

If only we'd known about the wonderful (and free!) PDF-XChange Viewer from Tracker Software Products:

http://www.docu-track.com/home/prod_user/pdfx_viewer/

It won't do everything that Acrobat does (for example, merge annotations from multiple PDF files), but it includes a wide range of PDF annotation tools. And that means you could send PDF galleys by email rather than sending paper galleys by postal mail. How much money would that save you? A 300-page book at 2.5 cents (or more) per page to print or photocopy comes to $7.50. If you make three copies (for two proofreaders and the author), that's $22.50. Add postage of, say, $4.60 X 3 = $13.80, for a grand total of $36.30:

http://postcalc.usps.gov/

If you want overnight delivery (deadlines, right?), you're looking at postage of about $65, for a grand total of $87. And that doesn't include mailing envelopes, time spent copying and mailing, or the time cost of losing at least two days in transit. How many books do you handle a year? Ouch!

So, would PDF proofreading work for you? If you'd like to find out, PDF-XChange Viewer could be the way to go.

http://www.docu-track.com/home/prod_user/pdfx_viewer/

_________________________________________

READERS WRITE

After reading "Deleting Multiple Comments" in the previous newsletter, Greg Ioannou wrote to explain that in Word 2003 and 2007, no macros are needed to delete multiple comments:

From Word's help files:

- To quickly delete all comments in a document, click a comment in the document. On the Review tab, in the Comments group, click the arrow below

Delete, and then click Delete All Comments in Document.

It is a bit more complex for just one reviewer:

- On the Review tab, in the Tracking group, click the arrow next to Show Markup.

- To clear the check boxes for all reviewers, point to Reviewers, and then click All Reviewers.

Click the arrow next to Show Markup again, point to Reviewers, and then click the name of the reviewer whose comments you want to delete.

- In the Comments group, click the arrow below Delete, and then click Delete All Comments Shown.

______________________________________

Ron Solecki wrote:

I think I've found something "new" in Word. Well, it is not documented in any of the M$ Word books I have, the online help, M$ KB (but finding anything specific there is a minor miracle, I suppose it may be buried in there somewhere), or a Google search (first 26 entries) ... so something "new"!

What is this new thing? It is a way of providing fine control displaying levels in View / Outline.

The previously documented methods I've found are:

1. default keyboard shortcuts, ALT + SHF + 1-9, +/- , A

2. outline toolbar, "+" and "-" buttons to open close a selected heading

3. outline toolbar, dropdown "Show Level #" list

4. outline toolbar, "Show Level" buttons (older versions of Word)

5. macros, assign macro to user defined toolbar buttons to recreate the old button method

6. click on the "+" sign beside the heading level in outline view

Now there is a 7th!

7. Document map.

I found that displaying the document map when in outline view provides finer control over the heading levels displayed. In the past I never used the document map with outline view. Why bother, they show the same thing, condensed headings. Occasionally I would use the document map because it provided a slightly more condensed (smaller text) view to jump around in the doc.

The new thing I found is that I can use the document map to provide fine level control in the outline view. This is how ...

- display outline view: View / Outline

- concurrently, display the document map: View / Document map

The two displays are "in sync" showing the same levels. The first 5 methods described above affect the whole document, and clicking on the "+" sign beside a level in outline view opens up everything below it, including the text, which is more detail than I want to see.

Right clicking in the document map displays a drop down with "+/-" signs and "Show Level" options. I've found the "+/-" options unpredictable in the document map, and the "Show Level" choices work exactly like the toolbar option (probably invoke same command) affecting the whole doc.

The "new" thing is that clicking on the "+" sign beside a heading in the Document Map only opens up the specific heading 1 additional level at at time, unlike when you do it in the Outline view, which opens up everything (including text!). And no matter how far down you click in the document map, it will only expand the associated outline view to display headings, never body text!

The result is that you can have the whole document in outline view displaying only level 1 except for 1 heading that you have drilled down as many heading levels as you want using the document map. I've gone down 6 or 7 levels to organize the headings at that level.

It makes sense since both document map and outline view work with heading styles. And the one way fine control makes sense for the same reason. The document map can only display headings, never body text.

I have tested this in Word 2002/XP.

I also tried it in Word 97. But Word 97 has (always had, in my experience) problems displaying in outline view. I found that it has a bad habit of arbitrarily displaying body text in the document map and outline view seemingly at random, making it hard to confirm this tip. Reapplying "Normal" style hides the unwanted displayed text, but it does not always 'stick'.

Many thanks to Greg and Ron!

_________________________________________

RESOURCES

If you're interested in self-publishing or setting type with Microsoft Word, you'll find some interesting information on Aaron Shepard's Publishing Page:

http://www.aaronshep.com/publishing/index.html

Deleting Multiple Comments

While editing in Word, you may use Word's Comments feature (Insert > Comment) to insert questions for your client--or possibly your client has used comments to insert questions for you. In either case, there will probably come a time when you need to remove the comments so the file can be used for typesetting. But deleting comments one at a time can be a real pain.

The solution? A trusty macro, of course. Here's a simple macro that will delete all the comments in a document:

Dim aComment
For Each aComment In ActiveDocument.Comments
aComment.Delete
Next

If you don't know how to use such macros, you'll find instructions here:

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

But what if there are comments you don't *want* to delete? For example, what if the only comments you want to remove are the ones you created? The following macro will do the trick:

Dim aComment
For Each aComment In ActiveDocument.Comments
If ActiveDocument.Comments(1).Initial = "JML" Then
aComment.Delete
End If
Next

Just put your own initials in the macro in place of "JML" and off you go--comments deleted; problem solved.

_________________________________________

RESOURCES

Making Word Work for You: An Editor's Intro to the Tool of the Trade, by Hilary Powers

ISBN: 978-1-880407-22-6

If you've spent much time in user groups related to Microsoft Word and freelance copyediting, you're probably familiar with the helpful and distinctive postings from Hilary Powers, an expert word-whacker and one of the most respected and successful freelancers I know. When Hilary talks, people listen. And now for the big news: Hilary has released her long-awaited book, Making Word Work for You! You can learn more about the book here:

http://www.the-efa.org/res/booklets.html

Here's the "official" description: "Successful freelance editor Hilary Powers explains how to get the most out of Microsoft Word when editing manuscripts on screen. Among the subjects she covers are personalizing the program and the screen to meet your needs and taste, deploying Word's custom features, domesticating Track Changes, creating and using macros and templates, coping with the snares and pitfalls Word users often encounter, and finding useful resources and program add-ins. With this guidance, editors can increase their page-per-hour throughput--and their income."

Making Word Work for You is available from the Editorial Freelancers Association as a printed booklet and as a downloadable PDF file, both for a price that is less than a lunch at the food court in the mall. If your time is worth anything, you *must* read this book. Nobody--and I mean nobody--understands how to wring productivity out of Microsoft Word the way Hilary does. Don't wait--get this book *now* and follow Hilary's advice. You'll be glad you did. You can buy the book here:

http://www.lulu.com/content/1175135

Many thanks to Hilary for providing such a valuable resource.

Deleting Multiple Bookmarks

Bookmarks in a Word document are useful for many things, such as, well, marking your place, marking ranges for index entries, and marking text for cross-references. But they can also get in the way--for example, if you've finished editing a document for a client and have several dozen bookmarks you've created but now need to delete, or if you're getting ready to import a Word document into QuarkXPress or InDesign, which don't like bookmarks.

The usual procedure for deleting bookmarks is to click Insert > Bookmarks, select a bookmark, and click the Delete button--over and over and over again, since Word won't let you select more than one bookmark at a time.

The solution? A trusty macro, of course. Here's a simple one that will delete all the bookmarks in a document:

Dim aBookmark
For Each aBookmark In ActiveDocument.Bookmarks
aBookmark.Delete
Next

If you don't know how to use such macros, you'll find instructions here:

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

But what if your client included bookmarks that you don't *want* to delete? What if the only bookmarks you want to remove are the ones *you* created? Well, if you've started those bookmarks with a unique identifier, such as your initials, the solution is easy. For example, my initials are JML, so I name my bookmarks something like this:

JMLchapter12

JMLsection14

Then, when I'm finished editing, I run the following macro to delete them:

Dim aBookmark
For Each aBookmark In ActiveDocument.Bookmarks
If Left(aBookmark.Name, 3) = "JML" Then
aBookmark.Delete
End If
Next

Just put your own initials in the macro in place of "JML" or use some other unique code such as "zzz" (yes, the macro is case-sensitive).

Bookmarks deleted; problem solved.

_________________________________________

READERS WRITE

After reading "The Need for Speed" in the June 14 newsletter, Bill Rubidge wrote:

One suggestion I would add, since it is so basic, is "Learn to use the keyboard whenever possible, rather than the mouse. And I'm not necessarily suggesting learning and memorizing the keyboard commands--I'm just suggesting using the keyboard Alt keys to access the Word menus and move through them to the command you want and would otherwise access via numerous mouse moves and clicks. Once you display the keyboard commands (use the options to do this), learning to use the keyboard instead of the mouse is pretty quick."

Many thanks to Bill.

_________________________________________

RESOURCES

PDF XChange Viewer

I've long used Adobe Reader to view PDF files:

http://www.adobe.com/products/acrobat/readstep2.html

Unfortunately, not having the full version of Acrobat, I haven't been able to annotate PDF files for such things as indexing or typesetting corrections--until now.

What's changed? I've discovered the free PDF XChange Viewer:

http://www.docu-track.com/downloads/users/

The Docu-Track website says you can use the program to "View, Print, Export Text & Images, and add content to PDF files, type on PDFs in any font, fill and save forms, and much more!" It also describes the program as "the free alternative to the Adobe PDF Viewer/Reader--fully featured, faster, and still free!"

Note that it's "still" free--implying that later it may not be, so you'd better get it while you can:

http://www.docu-track.com/downloads/users/