Envelope w/ InsertAddressfromOutlook Macro - zip barcode

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Thanks to Graham - I have my envelope printing correctly and with a logo!
Now, I would like to know how I can set up the envelope with a macro that
asks me to enter the zip code so that it will automatically insert the zip
bar code (without me having to go through all these steps each time:
Insert>Field>BarCode)... Thanks so much for any assitance - you guys have
helped me so much.
 
The trick here is to insert the BARCODE field in your template with a
bookmark reference. Then bookmark the address area. I just wish I knew how
the trick was done! I have old envelope templates where the address frame is
somehow bookmarked (so that the bookmark is not overwritten when I type in
an address), but I can't replicate this in new documents. <sigh>

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
We don't use US barcodes in the UK and to experiment with them would need me
to setup my PC in US format, which I have not done, however if my
understanding of how the barcode works is correct, the following
modification to the macro used to insert addresses from Outlook (and
included in my envelope templates) *should* add a barcode field to the end
of the address.

From what I can gather the barcode field will use the bookmarked address to
compile the barcode. If that is correct, then the following should work as
the macro bookmarks the address and and inserts a barcode field with that
bookmarked content.

Near the bottom where the address is being selected you will see Count:=3 .
You may have to change that to Count:=2.
Let me know how you get on with this for if it works I will add the code to
the web page for the benefit of US users.

I have also bounced this to fellow MVP Greg Maxey who may be persuaded to
test it for me :)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>




Public Sub InsertAddressFromOutlook()

Dim strCode, strAddress As String
Dim iDoubleCR As Integer
'Set up the formatting codes in strCode

strCode = "<PR_GIVEN_NAME> <PR_SURNAME>" & vbCr
strCode = strCode & "<PR_COMPANY_NAME>" & vbCr
strCode = strCode & "<PR_POSTAL_ADDRESS>" & vbCr

'Let the user choose the name in Outlook
strAddress = Application.GetAddress("", strCode, False, 1, , , True,
True)

'Eliminate blank lines by looking for two carriage returns in a row
iDoubleCR = InStr(strAddress, vbCr & vbCr)
While iDoubleCR <> 0
strAddress = Left(strAddress, iDoubleCR - 1) _
& Mid(strAddress, iDoubleCR + 1)
iDoubleCR = InStr(strAddress, vbCr & vbCr)
Wend
'Insert the address
Selection.TypeText strAddress
'Select the address block
Selection.MoveUp Unit:=wdLine, Count:=3, Extend:=wdExtend
ActiveDocument.Bookmarks.Add Range:=Selection.Range, Name:="sZip"
'Move to the end of the address and add the barcode
Selection.EndKey Unit:=wdStory
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"BARCODE sZip \b", PreserveFormatting:=True

End Sub
 
O.k. I cut and paste the new macro you have below and it gave me a syntax
error at this entry "'Let the user choose the name in Outlook
strAddress = Application.GetAddress("", strCode, False, 1, , , True,
True)" - so I replaced that section with the original entry that was
downloaded from your website. So that's fixed.

Then I got a syntax error at this entry: Selection.Fields.Add
Range:=Selection.Range, Type:=wdFieldEmpty, Text:=
_
"BARCODE sZip \b", PreserveFormatting:=True

I don't understand a lot of the functions of macros, so I can't tell what
the error is.

Any help would be appreciated.
 
Back
Top