Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2004

Tip: Looking for answers? Try searching our database.

Macro to insert field-barcode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dmposey - 30 Dec 2004 03:03 GMT
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
Charles Kenyon - 30 Dec 2004 03:50 GMT
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.
Signature


Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

>I have a word doc that we are using to send to multiple companies.  I am
>not
[quoted text clipped - 14 lines]
> Thanks & Happy New Year
> dmposey
dmposey - 30 Dec 2004 04:37 GMT
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

> 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
[quoted text clipped - 20 lines]
> > Thanks & Happy New Year
> > dmposey
Charles Kenyon - 30 Dec 2004 07:06 GMT
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.
Signature


Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

> 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
[quoted text clipped - 38 lines]
>> > Thanks & Happy New Year
>> > dmposey

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.