URGENT:Is it possible to replace data character with another chara

F

foxcole

(Apologies if this is a common question. I've looked all through the Help
file, knowledge base and discussion groups and haven't found the right
combination of words to find anything useful... even if it's to say that what
I want isn't possible.)

In the data source, telephone numbers are in text format separated by dots
(for example, 555.123.4567). The requester wants to replace the dots with
hyphens in the merged letter, but I can't see a way to do this. This is the
first merge I've tried with Word 2003, and I do mail merges very rarely
anyway, so what perhaps should be obvious, isn't. I would be very grateful
for any help, but I also need to send the letter out this afternoon, so it is
rather urgent.

Cheers!
---Fox Cole
 
P

Peter Jamieson

If the phone numbers have a completely consistent format, the simplest thing
to do is probably to
a. output the merge to a new document
b. use WOrd Find/Replace, switch on the Use Wildcards option, and replace

([0-9]{3}).([0-9]{3}).([0-9]{4})

by

\1-\2-\3

To explain in case you need to change things a bit,

[0-9] makes Word look for character "0" to character "9"
{3} makes Word look for 3 of them
([0-9]{3}) makes Word treat those 3 characters as an "expression" that you
can reference using a number in the replacement text. The first expression
is numbered 1, so
\1 says "use the text you found in expression 1" in the result.

If the data source can be opened in Word you could consider making the
replacement there instead.

The alternative is really to open the data source using VBA and a piece of
SQL that does the replacement, but that is IMO harder and is only possible
if there are 255 columns or fewer in the data source.

If you have other numbers formatted nnn.nnn.nnnn that you want to keep that
way. then you would need to distinguish them in some way. but let's not go
there unless we have to.

Peter Jamieson
 
F

foxcole

Peter Jamieson said:
If the phone numbers have a completely consistent format, the simplest thing
to do is probably to
a. output the merge to a new document
b. use WOrd Find/Replace, switch on the Use Wildcards option, and replace

([0-9]{3}).([0-9]{3}).([0-9]{4})

I was hoping for a way to code it into the merge field, but this solution
works just fine too. Thank you, Peter, for the quick reply!

Cheers!
---Fox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top