24 June, 2013

Search and replace special characters in Word

Trying to find or replace special, non-viewable characters in Word? It's easy if you know how! Once you know how, you'll find many new uses. For example, I recently received a table of values in an email, and when I copied into Excel the values didn't go to the cells.

With a little search and replace in Word, I reformatted the data so it was tab delimited, and then opening in Excel was a snap. In this case, I had three columns of data, all separated by various number of spaces so that it looked nice in the email. This is how to replace the spaces with tabs.
  1. When replacing several spaces at once, the trick is to find and replace the longest number of spaces first. This had some column spaces with 4 spaces, 5, spaces, and 6 spaces, so I started with searching for 6 spaces.
  2. Open the Find and Replace dialog box (Ctrl-H).
  3. Put 6 spaces in the "Find what:" field.
  4. In the "Replace with:" field, enter "^9".
    Note the following:
    1. No quotes
    2. "^" is the character above the "6" on your keyboard (Shift-6)
  5. Click "Replace All."
    This will replace all the instances where there are 6 spaces.
  6. Repeat the process for each of the smaller number of spaces, e.g. 5, then 4.
  7. Copy and paste the final results into Excel.
If you're still with me, you learned that using the caret ("^") followed by a code will allow you to either find and/or replace hidden characters. Here are a list of frequently used codes.
Tab ^9 or ^t
Page or section break ^12
Replace with clipboard contents (Replace only) ^c
Graphic ^g
Paragraph ^p
ASCII character number ^nnn
where nnn is the character number in decimal
ANSI character number ^0nnn
where nnn is the character number in decimal
Caret character ^^
Any number ^#
Any letter ^$
Em dash (Find only) ^+
En dash (Find only) ^=