What's That Character?

Here's the scenario: You open a giant document from a client and start looking through it. But what's this? The same odd character at the beginning of every paragraph. Must be some kind of file translation error. Odder still, Microsoft Word won't let you paste the character into its Find and Replace dialog, so how are you going to get rid of them all? By hand? Horrors!

If you knew the character's numeric code, you could search for it, as explained in our last newsletter:

http://www.topica.com/lists/editorium/read/message.html?sort=d&mid=1704081834

But this character isn't on the usual list. How can you find out its numeric code? By using our trusty NextCharacter macro:

FOR MICROSOFT WORD 6 OR 7 (95):

'THE MACRO STARTS HERE
NextChar$ = Str$(Asc(Selection$()))
MsgBox "The code for the next character is " 
+ NextChar$ + ".", "Next Character"
'Macro ends here
FOR MICROSOFT WORD 8 (97 OR 98) OR 9 (2000 OR 2001):
'Macro starts here
Dim NextChar$
NextChar$ = Str(Asc(WordBasic.[Selection$]()))
WordBasic.MsgBox _
"The code for the next character is " + NextChar$ + ".", _
"Next Character"
'THE MACRO ENDS HERE

TO CREATE THE MACRO

1. Copy the appropriate macro from this newsletter.

2. Click the "Tools" menu at the top of your Word window.

3. Click "Macro."

4. In Word 97, 98, 2000, or 2001, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Type a name for the macro in the "Macro Name" box--"NextCharacter" should do nicely.

7. Click "Create."

8. Paste the macro at the current insertion point.

9. In Word 6 or 7, click "File," then "Close," then "Yes." In Word 97, 98, 2000, or 2001, click "File," then "Close and Return to Microsoft Word."

TO RUN THE MACRO:

1. Put your cursor in front of the character whose numeric code you want to know.

2. Click the "Tools" menu at the top of your Word window.

3. Click "Macro."

4. In Word 97, 98, 2000, or 2001, click "Macros."

5. Make sure "Macros Available In" shows "Normal.dot."

6. Select the macro (probably "NextCharacter") in the "Macro Name" box.

7. Click "Run."

After you run the macro, a message box will appear on your screen with the numeric code you need.

Searching with Microsoft Word's Built-in Codes

Our last newsletter explained how to search for special characters (such as carriage returns and section breaks) using character codes. You can read the newsletter here:

http://www.topica.com/lists/editorium/read/message.html?sort=d&mid=1703875043

Why should you, as an editor, writer, or publisher, care about something as "technical" as searching with codes? Because they make it possible to find and replace things you ordinarily couldn't, such as paragraph breaks, dashes, and symbols. This can be a big help in cleaning up all kinds of editorial and typographical problems that you'd otherwise have to fix by hand.

After reading the last newsletter, subscriber Bruce White wrote: "Next obvious question: Where can we find a full list of codes?"

There are actually two different kinds of codes:

1. Microsoft Word's built-in codes (such as ^p for paragraph breaks and ^t for tabs).

2. ANSI character codes (such as ^013 for paragraph breaks and ^009 for tabs).

Both kinds of codes are useful, but the list of ANSI codes includes every character you can use in Microsoft Word. Next week I'll provide a list of these codes and explain how to use them.

This week, I'll give you a list of Word's built-in codes, which you can use in Microsoft Word's Find and Replace dialog (Edit/Replace). For example, if you wanted to find an em dash, you'd enter the following code in the "Find what" box:

^+

To replace it with an en dash, you'd enter this in the "Replace with" box:

^=

You can also insert Word's built-in codes by clicking the Special button in the Find and Replace dialog and then selecting the item you need. Please note that you can use some of the codes only in finding text, others only in replacing, and others in either one.

You can also use combinations of codes. For example, you could search for tabs followed by paragraph breaks (^t^p) and replace them with paragraph breaks alone (^p).

And now, here's the list. Enjoy!

CODES YOU CAN USE IN THE "FIND WHAT" BOX

Annotation mark ^a

Any character ^?

Any digit ^#

Any letter ^$

Caret character ^^

Column break ^n

Em dash ^+

En dash ^=

Endnote mark ^e

Field ^d

Footnote mark ^f

Graphic ^g

Line break ^l

Manual page break ^m

Nonbreaking hyphen ^~

Nonbreaking space ^s

Optional hyphen ^-

Paragraph mark ^p

Section break ^b

Tab character ^t

White space ^w

CODES YOU CAN USE IN THE "REPLACE WITH" BOX

Caret character ^^

Clipboard contents ^c

Column break ^n

Contents of the Find What box ^&

Em dash ^+

En dash ^=

Line break ^l

Manual page break ^m

Nonbreaking hyphen ^~

Nonbreaking space ^s

Optional hyphen ^-

Paragraph mark ^p

Tab character ^t

Searching with Character Codes

In our last newsletter, I explained how to find Microsoft Word footnote numbers using the character code ^02. You can read the newsletter here:

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

There are other character codes you can use to find certain items:

* For a carriage return, you can use ^013.

* For a section break, you can use ^012.

* For a word space, you can use ^032.

Of course, you can also use Word's built-in codes, which you can insert into the Find dialog's "Find what" box by clicking the "Special" button:

* For a carriage return, you can use ^p.

* For a section break, you can use ^b.

* For a word space, you can use ^w for a word space (actually, any white space).

So why would you want to use the first codes?

Because if you're finding something by using wildcards, the second ones won't work. For example, let's say that (for some reason) you're searching for "wh" followed by any other character (the wildcard for which is "?"), followed by a carriage return. In the Find dialog's "Find what" box, you enter this:

wh?^p

And to make Word search for the wildcard rather than an actual question mark, you put a check in the box labeled "Use wildcards."

Finally, you click the Find button. What happens? You get an error message:

"^p is not a valid special character for the Find What box or is not supported when the Use Wildcards check box is selected."

"Well then, how," you politely ask your computer, "am I supposed to find what I'm looking for?"

As usual, it doesn't reply, but here's the answer anyway. In the "Find what" box, you enter this:

wh?^013

And that will do the job.

Ordinarily, you should probably use Word's built-in codes, such as ^p and ^b. But when those don't work, now you've got an alternative.