L
Laura Townsend
Greetings,
I have a little routine that adds a barcode field to the end of an address
(for the zip code).
To determine which part of the address is the zip code, it starts at the end
and goes backwards as long as it sees consecutive numbers and/or a dash.
My problem is that some users have gotten endashes and em dashes in their
zip codes instead of a regular dash. I don't know how to include them in
the character set. Copy/paste just put a regular dash in the VBA code. I
don't know their ascii value and wouldn't know how to include something like
that in the character set if I did.
Any suggestions? Below is the code of my little procedure. It starts with
the selection at the end of the address. (Feel free to recommend a more
elegant way to do this, too -- but my big concern is en/em dashes.
Many Thanks in advance!
Laura
Private Sub AddBarCode()
Dim rngZipCode As Range, sZipCode As String
Set rngZipCode = Selection.Range
rngZipCode.MoveStartWhile cset:="0123456789-", Count:=wdBackward
sZipCode = rngZipCode.Text
Selection.TypeParagraph
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"BARCODE \u " & sZipCode, PreserveFormatting:=True
Selection.Collapse wdCollapseEnd
End Sub
I have a little routine that adds a barcode field to the end of an address
(for the zip code).
To determine which part of the address is the zip code, it starts at the end
and goes backwards as long as it sees consecutive numbers and/or a dash.
My problem is that some users have gotten endashes and em dashes in their
zip codes instead of a regular dash. I don't know how to include them in
the character set. Copy/paste just put a regular dash in the VBA code. I
don't know their ascii value and wouldn't know how to include something like
that in the character set if I did.
Any suggestions? Below is the code of my little procedure. It starts with
the selection at the end of the address. (Feel free to recommend a more
elegant way to do this, too -- but my big concern is en/em dashes.
Many Thanks in advance!
Laura
Private Sub AddBarCode()
Dim rngZipCode As Range, sZipCode As String
Set rngZipCode = Selection.Range
rngZipCode.MoveStartWhile cset:="0123456789-", Count:=wdBackward
sZipCode = rngZipCode.Text
Selection.TypeParagraph
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"BARCODE \u " & sZipCode, PreserveFormatting:=True
Selection.Collapse wdCollapseEnd
End Sub