Skip to main content

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

mail-mergeable-barcodes-in-microsoft-word-2013-aka-bar-codes

Before you start

The Word feature this Hub uses is only in Word 2013, 2016, 2019 and Word 365 for Windows. Not Word for Mac. 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 for Windows

Need some barcodes? Microsoft very quietly brought barcodes back in Word 2013, 2016 and 2019 for Windows (only) 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 though 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. But you can't beat FREE.

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 say it as it is: 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 below to make Word show those characters.

  1. Make sure you're using Word 2013, 2016, 2019 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. (Skip this step if you're just inserting a barcode based on hard-coded data--not mail-merged data.) 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 the example above

Result of DISPLAYBARCODE for the 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, 2019 or 365 for Windows (no Macs), and must use the docx format
  • Manual field coding is required. Grrrrr!
  • You can send documents containing DISPLAYBARCODE to others, but they must have Word 2013, 2016, 2019 or Word 365 for Windows. 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
  • If you need to put Tab or Enter (aka "control characters) in the barcode's data to separate multiple fields: unfortunately DISPLAYBARCODE doesn't let you input them. Note that only a few barcodes types like QR and Code 128 theoretically could support control characters, even if DISPLAYBARCODE did.
  • 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

Scroll to Continue
  • 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.
  • Typically have an "escape" mode that allows you to enter control characters like Tab and Enter (for barcode types where that's possible).
  • 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 (parentheses at the beginning)

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

DISPLAYBARCODES simply cannot generate this. It's a variant of Code 128 but has a magic invisible marker called FNC1 inside the barcode. See Alternatives and workarounds, above.

Poll

This article is accurate and true to the best of the author’s knowledge. Content is for informational or entertainment purposes only and does not substitute for personal counsel or professional advice in business, financial, legal, or technical matters.

© 2014 Mister Word

Comments

Mister Word (author) from Californiaaah on February 23, 2020:

@agus writes "I have printed the barcode in Excel by mail merge, but the result does not appear in the barcode"

Sorry, your comment is much too vague for me to make any specific comments. Again, these instructions work as written for Word 2013 and later (Windows only), but you must follow them *exactly*.

Also, please post in English. Use Google translate if necessary.

Mister Word (author) from Californiaaah on May 28, 2019:

@jpa57 Thanks for that detail. It's not that surprising since I'm told that Word for Mac is completely different under the covers.

jpa57 on May 28, 2019:

Great writeup. One shortcoming to add is that this doesn't seem to work at all on a mac. I am sharing files between mac and windows10 running office 365, both the data source and the label source, and I have a merged file that works great on windows but just says "Error!" in each cell on the mac. I tried a variety of different formats for the data source but it appears to be in the DISPLAYBARCODE capability itself.

Mister Word (author) from Californiaaah on September 07, 2018:

@G This is a general mail-merge question that's not specific to barcodes, so I'd best refer you to other general resources. Barcode data works exactly the same as regular text.

Search the web for "NextRecord" or "Next Record" in Word. All will be revealed.

G on September 07, 2018:

I have ten rows (and in the future, thousands) in Excel with different part numbers I am trying to generate barcodes for. When I follow these directions, it just keeps creating the same barcode over & over (row 1 only). How do I get unique barcodes for each row to display within the word doc?

Mister Word (author) from Californiaaah on June 08, 2018:

@Leuh Tab and Enter are special characters called "control characters." No way of entering control characters in DISPLAYBARODE that I know of. I should add that fact to the Limitations & Problems section of the article.

Mind you: only a few barcode types like QR & Code 128 are designed to theoretically support those kinds of characters, whether in Word or anywhere else.

Some addins have a "data escaping" mode that lets you write something like ~d009 for Tab and ~d013 for Enter. Of course, that's only for the barcode types that do support control characters.

Leuh on June 08, 2018:

Is there a way to code [tab] or [enter] in this?

Mister Word (author) from Californiaaah on March 20, 2018:

@Robert Thanks for that info! I'm sure your comment will help quite a few people.

Robert Delage on March 20, 2018:

ERROR with \q switch:

When using DISPLAYBARCODEs or MERGEBARCODES in Word 2016 (not sure on previous version) the \q switch does not work with [0..3] but rather with [L, M, Q, H]. If you use a [0..3] digit it always produce a QR code with Q level error correction.

Mister Word (author) from Californiaaah on December 26, 2017:

@MSK DisplayBarcodes doesn't work with email merges as mentioned in the Limitations and Problems section of the article. See the Alternatives and Workarounds section for just that.

MSK on December 26, 2017:

This is working well for word. But later word is not getting emailed. It is getting failed with error message " Too long line was received. Transmission aborted."

Can anyone help me on this ?

Paul Licari on November 25, 2017:

Thanks for the information.

I will give it a try and see how it works

Roger on October 13, 2017:

When using MERGEBARCODE the barcode will also be displayed in an email (HTML). This isn't the case when using DISPLAYBARCODE as you mentioned already.

Grateful on August 15, 2017:

Thank you. This worked for me today. Gratitude for sharing. But you are right... Follow instructions exactly.

As my grandmother would have said, "You have earned another jewel in your heavenly crown."

Mister Word (author) from Californiaaah on June 07, 2017:

@Christen I'm not sure what's going on since I can't see your screen, but are you using Mailings + Insert Merge Field, or are you manually inserting the field code? It's very easy to mess up field codes if even a single space is wrong, which is why I recommend Insert Merge Field.

Make sure you have "double quotes" around the merge field.

Also, certain types of bar codes expect number-only data, so any commas, dollar signs, spaces, etc. in the data might get you an error. As a test, I'd try merging the same field into your document as plain text to see what it's about.

Christen on June 07, 2017:

You're right - I can't find ANYTHING else on this topic online... frustrating!! I'm having an issue in step 7, when I go to insert a merge field it gives the error "Required parameters are missing or incorrect". Any idea why I'd get that error? Also, it worked fine if I just entered "1001" for example - but then all of the barcodes reflect "1001". If I go this route, any way to get a sequence of numbers vs. a repeat of the same number?

THANK YOU SO MUCH!!!

Mister Word (author) from Californiaaah on April 12, 2017:

@waldirs Thanks! I would never have guessed that in 1000 years.

Waldirs on April 12, 2017: