DISPLAYBARCODE and MERGEBARCODE: How to Insert or Mail Merge Barcodes (Bar Codes) Word 2013, Microsoft Word 365

Source

Before you start

The Word feature this Hub uses is only in Word 2013, 2016 and Word 365. If you have an earlier version of Word or if Word's bare-bones features don't meet your needs, you'll need a third-party solution; see the Alternatives and workarounds section below for some advice.

If you already have image files containing barcodes and want to mail merge those instead of generating new ones, see my Hub about IncludePicture.

Free barcode generator in Microsoft Word

Need some barcodes? Microsoft very quietly brought barcodes back in Word 2013 and 2016 after dropping them back in 2007. There's very little information available about using the DISPLAYBARCODE field, so I'm here to fix that.

DISPLAYBARCODE is free and very basic. Yes, it does generate barcodes, but it's missing many of the options and features that you may need. Also, we're going to have to get our hands dirty with some manual Word field coding.

DISPLAYBARCODE vs. MERGEBARCODE

Don't use MERGEBARCODE even though the name sounds right. Use DISPLAYBARCODE instead.

You may see some references to MERGEBARCODE on the web. Well... the documentation for that feature seems to be wrong. It doesn't create barcodes! I suspect it's supposed to be a variant of the MERGEFIELD field for use within DISPLAYBARCODE, but MERGEFIELD works just fine and is conveniently supported by Mailings, Insert Merge Field on the Ribbon Bar.

Please leave a comment if you have better info about MERGEBARCODE.

Barcodes step by step

We're going to do some manual field coding, and let's be honest: field coding is right up there with doing your own taxes. It's painstaking work and Microsoft Word doesn't help you at all. So, block out some uninterrupted time and please try to follow these instructions exactly as written. Always enter spaces if and only if instructed.

Also, you must not copy & paste the examples shown, and you must not type in the { and }'s nor the .'s (i.e. not the curly braces or periods) shown below. It won't work. Use the procedures described to make those characters appear.

  1. Make sure you're using Word 2013, 2016 or 365 (not earlier) and that your Word document is in the newer (.docx) format. The old .doc format doesn't support these barcodes.
  2. (If you're just inserting a barcode based on hard-coded data -- not mail-merged data -- ignore this.) Make sure your Word Mail Merge datasource is selected: Mailings, Select Recipients, Use an Existing List.
  3. Locate where you want the barcode and place Word's cursor there.
  4. Press Ctrl-F9 (i.e. press the F9 key while first holding down the Ctrl key). You'll see {.|.} Those periods are Word's way of displaying spaces within field codes; the vertical bar is your cursor. If you don't see them, press Ctrl-Shift-8 (i.e. while holding down both the Ctrl and Shift keys, press the "normal" 8 key -- not the one on the numeric keypad) to show them. Pressing again hides them.
  5. Without moving the cursor, type DISPLAYBARCODE You'll see {.DISPLAYBARCODE|.}
  6. Press the Spacebar once, then the " (double-quote) key. You'll see {.DISPLAYBARCODE "|.}
  7. Now for the data to barcode. If it's hard-coded, type the data. If you want to use a mail-merge field: Mailings, Insert Merge Field, <select from dropdown list>. You can insert several fields, and you can intersperse hard-coded text and fields. For example, you might see:
    {.DISPLAYBARCODE."{.MERGEFIELD.First_Name.}{.MERGEFIELD.Last_Name.}|.}
  8. Press the " (double quote) key followed by the Spacebar to close out the data. For example:
    {.DISPLAYBARCODE."{.MERGEFIELD.First_Name.}{.MERGEFIELD.Last_Name.}".}
  9. You must now type a code which selects the type of barcode you want. The full list is in Microsoft's DISPLAYBARCODE article, but here these are the most common:
    QR
    CODE128
    CODE39
    UPCA
    For example:
    {.DISPLAYBARCODE."{.MERGEFIELD.First_Name.} {.MERGEFIELD.Last_Name.}".CODE128|.}
  10. There are several option flags that you may enter. If you enter options, you must enter a space before the option, and between each option if you enter more that one. Again, the full list is on Microsoft's DISPLAYBARCODE article, but these are noteworthy:
    \t shows the human-readable text below the bars
    \h followed by a space and a number (in twips, which are 1/1440 ths of an inch) to set the height. Height includes any human-readable text.
    For example:
    {.DISPLAYBARCODE."{.MERGEFIELD.First_Name.} {.MERGEFIELD.Last_Name.}".CODE128.\t.\h.1440|.}
  11. Press Alt-F9 (the F9 key while holding down the Alt key) once or twice until you see your barcode.

Result of DISPLAYBARCODE for example above
Result of DISPLAYBARCODE for example above

Limitations and problems

On the plus side, there's nothing extra to buy or download to use DISPLAYBARCODES, and it's officially supported by Microsoft.

On the minus side

  • You must have the Word 2013, 2016 or 365, and must use the docx format
  • Manual field coding is required
  • You can send documents containing DISPLAYBARCODE to others, but they must have Word 2013, 2016 or Word 365. Other Word versions display nonsense text instead of barcodes
  • Merge to Email (Send Email Messages option of Finish & Merge) does not work. The barcodes don't appear in the sent emails.
  • DISPLAYBARCODE generates a limited range of barcode types
  • Some types of barcodes require checksum digits as the last character. These must be computed based on the rest of the data but, unlike many add-ins, Word doesn't generate them for all barcodes. In those cases, you must compute the checksums using Excel formulas or other software before creating the barcodes
  • Yet other types of information requires special internal formatting which Word doesn't do. See the later sections for a few notable ones.

Alternatives and workarounds

If DISPLAYBARCODES can't do the job for you or -- be honest -- is just too much of a hassle to set up, there are third-party solutions. Virtually all of them work will all Word versions and are available for most barcode types.

These break down into two main categories: traditional barcode fonts, and the modern barcode add-ins. I personally find add-ins much more convenient.

Barcode fonts

  • My own favorites are from ID Automation because they have the widest selection, though I'll admit they're pricey. Word's interface for using them is familiar since it's the same as regular text faces.
  • Set them up by inserting one or more regular text mail-merge fields, then selecting the barcode font for that text. You will need to use some Excel formulas to generate checksums or other characters for most barcode types; ID Automation, for one, ships Excel formulas with many of its fonts.
  • Each different barcode type and size requires its own particular font.
  • 2D barcode fonts (QR Code, Datamatrix, PDF417, etc.) are available, but are much too hard for non-IT-professionals to use.
  • Internal pre-formatting of data for vCard, advanced GS1-128, etc. needs to be done with Excel formulas.
  • If you send a Word document that uses barcode fonts to another computer, that computer needs to have exactly the same fonts, too. Typically, you must purchase a copy of the font for every computer.
  • Similarly, barcode fonts don't work with Merge to Email (Send Email Messages option of Finish & Merge) unless the recipient also has exactly the same fonts installed.

Barcode add-ins

  • My personal favorite is OnMerge Barcodes (limited free version available) because it's the easiest to use and has so many options.
  • Typically well integrated with Word, work with a pop-up dialog that lets you point and click to set up the data and choose options from a menu.
  • Take care of generating whatever checksums or other required data processing, meaning no Excel formulas. You can use any type of datasource supported by Word.
  • A few of them automatically generate vCard and advanced GS1-128.
  • When you mail merge to Edit Individual Documents (i.e. merge to a new document), the resulting document can be sent to any Word user even if they don't have a barcode add-in or font.
  • Likewise, these typically do work with Merge to Email (Send Email Messages option of Finish & Merge).
  • Shop around. Features, convenience and supported barcode types vary considerably.

QR Code
QR Code

vCard and MECARD contact information

Contact information is often placed in QR Codes so that smartphones can scan a barcode and automatically enter it in the contact list.To make this happen, the information must be formatted into the vCard or MECARD format before being made into a QR Code.

For example, the vCard data for somebody's name, job title, phone number and email might look like this:
BEGIN:VCARD
VERSION:2.1
N;CHARSET=UTF-8:Müller;John;;;
TEL:999-999-999
EMAIL;INTERNET:John@internet.com
TITLE:President
ORG:The Company
END:VCARD

DISPLAYBARCODE does generate QR Codes, but does not format data into the vCard format. You can generate this using an Excel formula, but there are no good resources I can link to. It seems that generating vCards is a trial-and-error process because the various smartphones do not really conform to standards -- they accept varying bits and pieces of the various vCard standards.

You can generate some vCard QR Codes on many sites on the Internet. Be sure to use foreign characters in your tests if your project requires them. If they work for a representative sample of phones you're targeting (please don't just test with your own phone!), you can reverse-engineer the vCard format they're emitting.

If you see digits in parentheses, it's GS1-128 -- not Code 128
If you see digits in parentheses, it's GS1-128 -- not Code 128

GS1-128 barcodes

If you see a few digits in parentheses at the beginning of the data for a 1-dimensional barcode, for example (00), this is actually a GS1-128, also known as UCC EAN 128. Such barcodes are commonly used for labelling and logistics.

It is a variant of Code 128 but has a special invisible marker called a FNC1 inside the barcode which DISPLAYBARCODES simply cannot generate. See Alternatives and workarounds, above.

Poll

What's your preferred barcode solution for Microsoft Word?

  • DISPLAYBARCODE
  • Barcode fonts
  • Barcode add-in
See results without voting

© 2014 Mister Word

More by this Author


Comments 23 comments

Miles 2 years ago

I have Word 2010. Will this work for me?


wordnut profile image

wordnut 2 years ago from Californiaaah Author

@Miles Sorry, only Word 2013 or later. There are no updates or Service Packs for older versions that make DISPLAYBARCODE available.


Walter 24 months ago

Hi I tried this and works well in word, but as soon as I send it as an email the codebar does not appear. Is there any way to fix this?

Im sending my clients invoice each month and I need for them to see the codebar in order to print and pay it.

Thank you


wordnut profile image

wordnut 24 months ago from Californiaaah Author

@Walter Thanks for pointing out the omission. Merge to Email doesn't work with DISPLAYBARCODE. I've updated the Limitations and Problems section of the article to explain this.


Owen 20 months ago

What code do I need to load the BARcode data from a field on the document or multiple fields. Everything I have tried doesn't work.


wordnut profile image

wordnut 20 months ago from Californiaaah Author

@Owen The examples in the article explicitly give detailed instructions and show examples for what you're requesting. They've been tested and are known to work.

I'm not exaggerating in the article when I say that manual field coding is painful and painstaking. Fields won't work if you so much as look at them the wrong way. In my my experience editing my other hub about using the IncludePicture field, several users complained that the instructions didn't work. In every single case, it turned out they weren't following the instructions 101% exactly as written.

This article does have a section that explores your options for alternative workarounds.


Jaroslav 17 months ago

It´s possible to set up fix height of QR code? When I generated an QR code their height is different for each data set.


wordnut profile image

wordnut 17 months ago from Californiaaah Author

@Jaroslav Check out the /h option in step 10 of the procedure in the article.


Django Lohn 15 months ago

Dear wordnut,

Because I found your post by accident and it helped me with a problem you might not even know that exists, I thought my input may be of assistance for future "googlers" =D

I found that the MERGEBARCODE option is working fine but you probably would prefer 1 code column in the Excel source that combines other data into one column so just 1 reference is needed in Word.

One interesting fact is that de QR code generated by MERGEBARCODE in the final finished merged document, creates a picture replacing the code and this picture contains very fine white lines between blocks within the QR code. Smartphones usually have no problem with this, but sometimes scanning software can have trouble with these lines.

Trying to prevent these wite lines your post got me trying one last desparate move: use the DISPLAYBARCODE with the MERGEFIELD and what do you know... the final finished merged documents have a perfect white-line-less QR code (instead of the picture)!


Willie 14 months ago

When I press the Ctrl-F9 key the periods do not appear in the brackets just the cursor does. I tried manually putting in the periods and the rest of the information and the bar code never appears. I am using Word 2013 and the docx file extension.


wordnut profile image

wordnut 14 months ago from Californiaaah Author

@Willie To make those "periods" appear, press Ctrl-Shift-8 i.e. while holding down both the Ctrl and Shift keys, press 8 (the one on the regular keyboard, not the 8 on the numeric pad). Doing the same thing again hides them.


Suresh 14 months ago

Hi,

Thx for the wonderful writing. But i am facing a problem, in Step 6 after pressing the space bar i get one additional "period" and not a space. How to over come this


wordnut profile image

wordnut 14 months ago from Californiaaah Author

@Suresh See my answer to @Willie immediately above.


suresh 14 months ago

Hi,

I did read that, but i do get to see the other two periods that are coming by default.

For e.g. the below is the text from your instructions

.DISPLAYBARCODE ".

But when i enter data and press the space bar once i get this

.DISPLAYBARCODE .".

Notice the additional period after E.


wordnut profile image

wordnut 14 months ago from Californiaaah Author

@Suresh I've revised the article to show the spaces/periods exactly as Word displays them.


Paul Southcott profile image

Paul Southcott 14 months ago

I have this working in word with no problem

I would like it to work in Publisher - I have tried using same settings as word but doesn't work.


wordnut profile image

wordnut 14 months ago from Californiaaah Author

@Paul I know nothing about Publisher. If anyone reading this has an answer, please feel free to jump in.


cory 14 months ago

This article is a gem, thank you.


FallingMan 12 months ago

"@Jaroslav Check out the /h option in step 10 of the procedure in the article."

I can get the /h to work for code128 etc but not QR codes, are you sure that syntax works for QR codes?


wordnut profile image

wordnut 12 months ago from Californiaaah Author

@FallingMan Turns out the \h option doesn't work for 2D bar codes. You can kinda use the \s xxx option instead, where xxx is the *percentage* of the bar code's original size, e.g. \s 200 is 200% of original size.

However, the overall size will vary depending on the data you encode in the QR. You cannot get Word to use a specific size for the overall bar code. The \s option scales the natural size up or down, but the catch is the "natural size." By default, Word makes the original bar code with each cell (dot) 1x1 mm square. That means that the overall size of the bar code will vary depending on how many cells are in the bar code, which in turn depends on the information is encoded in the QR.

You'd think that you could nail down the natural size of the QR code by always encoding the same number of characters of data, which you'd expect would result in QR codes having the same number of cells and consequently the same size. Unfortunately the number of cells depends on both the number of characters and on the characters themselves. Certain data patterns pack into a QR code more "tightly." This means that different data of the same length can produce different-sized QR codes.

So, it isn't a perfect solution, but \s may be work for you depending on how exactly you need to control the overall size. Otherwise, you can always fall back on 3rd-party solutions.


decimal639 7 months ago

I have a work project that does mail merge programmatically from a database. My boss now wants to add a QR code onto the letters I am creating. I tried your example for doing a mail merge into the item but the merge has been placing the value outside the DISPLAYBARCODE container instead of between the quotes. Anyone have any idea why this is happening and/or suggestions how to 0correct this? This isn't affecting any of the other merge fields, just the one inside the DISPLAYBARCODE container.


toonerty 7 weeks ago

Thanks for the explanation. Very precise, and now I've got VBA code creating a print catalogue with QR codes to link to our company's website.

However, I've noticed that for the same URL, an online QR Generator creates a 29x29 QR, and Word creates a 33x33 QR. That's 1089 vs 841 pixels, an overhead of about 30%.

Any ideas on how to get Word to create smaller QRs? Also, I've tried the 4 different \q settings and it creates exactly the same QR each time - I think....


wordnut profile image

wordnut 2 weeks ago from Californiaaah Author

@toonerty - Data is "encoded" (a crude form of data compression) into the pattern of bits in the bar code. QR supports several different encoding schemes intended for different purposes, e.g. all-numbers, capital letters and numbers, or full character set. Different encoding schemes compress different kinds of data better or worse. Using the wrong encoder for a given piece of data will result in less-efficient encoding, i.e. bigger bar code, but it will still scan.

It's up to the bar code generator to automatically choose the best encoding for your particular data. There's a surprising amount of work involved. Or, the encoder can just punt and always use the same encoding scheme no matter what, which is obviously less work for the person writing the bar code software. I don't have any inside knowledge, but that would be my guess.

BTW, the QR specification requires all QR scanners/decoders to support all encoding schemes, so always generating a single encoding wouldn't buy better compatibility with more scanners. Matter of fact, bigger bar codes make it slower and harder for scanners to "lock in" to them.

    Sign in or sign up and post using a HubPages Network account.

    0 of 8192 characters used
    Post Comment

    No HTML is allowed in comments, but URLs will be hyperlinked. Comments are not for promoting your articles or other sites.


    Click to Rate This Article
    working