Macro to insert field-barcode

D

dmposey

I have a word doc that we are using to send to multiple companies. I am not
using mailmerge. I am copying the address from one system and pasting into
my word document. Then I going to Insert--Field--Barcode--Bar Code is US Zip
Code. I would like to use a macro to insert the barcode but the zipcode
changes everytime. I tried adding a bookmark for the zipcode but that
changes everytime I change the name & address. I thought I could stop the
macro on the "FIELD" box option but that doesn't work either. I ended up
recording the macro with the zip code field blank. When I run it, I get "No
Zip Code" and then I right-click & select edit field to insert new zip code.
Is there an easier way to do this?

Thanks & Happy New Year
dmposey
 
C

Charles Kenyon

Try making your bookmark with extra leading and trailing spaces. Otherwise,
when you edit to the edge of a bookmark you usually delete the bookmark. I
put null macrobutton fields within the bookmark to hold the actual data that
I want there. These are preceded by the extra spaces. Note that the zipcode
barcode field will accept an entire three-line street address with city,
state and zip at the end without blinking.
 
D

dmposey

Thank you Charles for your help but I am still having trouble with this. I
guess I don't understand how to put a null macrobutton field within the
bookmark. How does the barcode pick up all three address lines? When I
select barcode from the field option, the 3rd box is for us postal zip code.

Sorry for being so ignorant!
Denise
 
C

Charles Kenyon

Bookmark the actual address area with some cushion spaces. A macrobutton
field with field codes displayed (Alt-F9) will look something like:

{ MacroButton NoMacro [Name] }

When field codes are hidden, it looks like:

[Name]

I usually format the prompt language to be blue or red text (but not the
entire field). That way it stands out as unfinished when you haven't typed
in all the fields.

When you click on it, the entire thing is selected. Typing replaces the
selection. You can move to the next one with the F11 key. Some macros to do
this are below. See http://addbalance.com/usersguide/fields.htm#MacroButton
for more on using macrobutton fields.

For the moment, assume that the brackets are bookmark delimiters. My
template's envelope address looks like:

Name
Street [
City ST 01234 ]

Moving among the macrobutton fields and replacing them does not mess up the
bookmark because of the cushioning spaces. The BarCode field uses the
bookmark.

The following subroutine selects a particular field. It is called by another
macro with the information about the field number. For instance, the
following command in a macro will go to the third field in the document body
(regardless of field type).

SelectIt(3)

Sub SelectIt(iField As Integer)
' Routine goes to beginning of document and then goes to field
' iField sets number of field to go to
' written by Charles Kenyon
'
Dim iNumber As Integer
Selection.HomeKey Unit:=wdStory
For iNumber = 1 To iField
Selection.NextField.Select
Next iNumber
End Sub

Otherwise, the following statement selects the next field in the document,
like pressing the F11 key:

Selection.NextField.Select

Hope this helps clarify.
 

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