Results 1 to 6 of 6

Thread: Postal bar code

  1. #1
    mick_571
    Guest

    Postal bar code

    I posted this in the VBA section, but this is probably a better place to start.

    Hi. I'm trying to add the postal bar code to multiple envelopes in Word97. We're not using Word's envelope feature. Instead, our users are able to select several addresses from a document and create envelopes for each address.

    I'm currently using code that searches for "[space][space]^#^#^#^#^#", copying the 5 digit zip code, adding the field code and pasting the zip code into the formula. This is working, but it's not fool-proof. This will only work if the user has entered 2 spaces before the zip code, which is not always the case.

    Does anyone have any other ideas on how to search for the zip code in an address? I'd like to create the envelopes on the fly and creating a separate mail merge document may end up being too time-consuming.

    Thanks for your help. [img]/w3timages/icons/clown.gif[/img]

  2. #2
    chris_k
    Guest

    Re: Postal bar code

    The following macro I created in W2K should insert the barcode on the bottom line of an envelope that has already had the address entered:

    Sub zipcode()
    '
    ' zipcode Macro
    ' Macro recorded 5/8/00 by Christine Kinsey
    '
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "ASK zip ""enter zip code""", PreserveFormatting:=True
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    Selection.EndKey Unit:=wdStory
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
    "BARCODE b zip", PreserveFormatting:=True
    End Sub

    Be sure you have placed a HrdReturn after your city, state & zip before you run the macro. I am not that proficient at creating macros and I'm sure that someone else could probably clean this up and streamline it.

    Hope this helps.

  3. #3
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Postal bar code

    Hi Mick:

    A slightly more accurate search would be to use wildcards & search for:

    [space]{1,}[0-9]{5}

    This searches for one or more spaces followed by 5 numbers. However, it will find [space][space]##### twice--once with two spaces & once with one space. It will also have a problem if the zip code is #####-####.

  4. #4
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,048
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Postal bar code

    You don't need to be quite so careful in your search target. The BARCODE field is pretty smart. If you have something that always follows the last line of the address in your envelope or selection (such as two paragraph marks), search for that, then select the preceding line (with or without the paragraph mark). Use that for your text.

    BARCODE "Marinette, Wisconsin 54143-0000"
    BARCODE "Marinette, WI 54143-0000"
    BARCODE "Marinette, WI 54143-0000"
    BARCODE "Marinette 35, Wisconsin 54143-0000" and
    BARCODE "54143-0000"

    all produce the same barcode, which is different from that produced by:
    BARCODE "Marinette, Wisconsin 54143"

    The field apparently is quite good at parsing the zip code. I often use it with a bookmark that covers the entire address including name and street. In writing this, though, when I tested the entire address bookmark I got a slightly different bar code with a 9-digit zip code. (With a 5-digit code the result was identical whether only the zip code or the entire address was used).

    [img]/w3timages/icons/smile.gif[/img]The envelope wizard produces the bar code that I get when I use the entire address.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    TBGOT
    Guest

    Re: Postal bar code

    In Word2000 there is a field code for barcode. I don't recall if Word97 has the same code. Go to Insert/Field/BarCode. That field gives you the opportunity to either use literal text or reference it to a bookmark within your document. Hope Word97 has this field...much easier to use.
    Good Luck,
    Jeri
    TBGOT

  6. #6
    mick_571
    Guest

    Re: Postal bar code

    Thanks, everyone. I'll try out your suggestions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •