
Signature
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP
My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Thank you very much, Graham, but the VB editor is not liking the "find" part
of the replace statement as I am using it. It flags the [0-9] after the
first [!0-9], and says "Compile error: expected: )". Here is the code as I
have it:
If Len(ZIP$) = 9 Then
Replace(ZIP$,([!0-9][0-9]{5})([0-9]{4}[!0-9]),\1-\2)
End If
I'm sure it's just a syntax error, but I'm not seeing it.
> If you can do this with fields in your document - see the Zip section of
> http://www.gmayor.com/formatting_word_fields.htm
[quoted text clipped - 15 lines]
> > "12345-6789", but will not work for "123456789". How can I change
> > "123456789" into "12345-6789"?
Russ - 07 Jul 2007 04:25 GMT
Paul,
Graham was not talking about using the Replace() function, he meant the
.Find method in Word VB*A*, which uses those wildcards. This forum is for
word.vba.general not VB.
However they are close enough that I would suggest using the format()
function.
ZIP$ = Format(ZIP$,"#####-####")
> Thank you very much, Graham, but the VB editor is not liking the "find" part
> of the replace statement as I am using it. It flags the [0-9] after the
[quoted text clipped - 28 lines]
>>> "12345-6789", but will not work for "123456789". How can I change
>>> "123456789" into "12345-6789"?

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Paul - 09 Jul 2007 15:56 GMT
Russ,
Thank you. The format function did the trick. Part of the problem was my
unfamiliarity with the barcode logic. I thought I needed some more complex
VBA code, when a simple VB statement was all I really needed.
Paul
> Paul,
> Graham was not talking about using the Replace() function, he meant the
[quoted text clipped - 36 lines]
> >>> "12345-6789", but will not work for "123456789". How can I change
> >>> "123456789" into "12345-6789"?