Skip to main content

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


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.


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:
  8. Press the " (double quote) key followed by the Spacebar to close out the data. For example:
  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:
    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:
ORG:The Company

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.


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


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?


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:

Answering to "Please leave a comment if you have better info about MERGEBARCODE":

If you just add Japanese as an editing language (no need to download anything), you'll see the "Insert Barcode Field" button under the "Mailings" tab. It's very easy to use and it inserts a MERGEBARCODE field that works.

Mister Word (author) from Californiaaah on November 18, 2016:

@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.

toonerty on October 11, 2016:

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....

decimal639 on April 27, 2016:

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.

Mister Word (author) from Californiaaah on November 13, 2015:

@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.

FallingMan on November 13, 2015:

"@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?

cory on September 25, 2015:

This article is a gem, thank you.

Mister Word (author) from Californiaaah on September 25, 2015:

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

Paul Southcott on September 25, 2015:

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.

Mister Word (author) from Californiaaah on September 14, 2015:

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

suresh on September 14, 2015:


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


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


Notice the additional period after E.

Mister Word (author) from Californiaaah on September 14, 2015:

@Suresh See my answer to @Willie immediately above.

Suresh on September 14, 2015:


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

Mister Word (author) from Californiaaah on September 11, 2015:

@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.

Willie on September 11, 2015:

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.

Django Lohn on September 03, 2015:

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)!

Mister Word (author) from Californiaaah on July 10, 2015:

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

Jaroslav on July 10, 2015:

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.

Mister Word (author) from Californiaaah on April 01, 2015:

@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.

Owen on April 01, 2015:

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.

Owen on March 25, 2015:

Words great for computer literate Users. Do you have code that take the value for the barcode from 1 or many fields within the word document. I have tried but just gives a bookmark error or missing parameter.

Mister Word (author) from Californiaaah on December 10, 2014:

@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.

Walter on December 10, 2014:

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

Mister Word (author) from Californiaaah on August 01, 2014:

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

Miles on August 01, 2014:

I have Word 2010. Will this work for me?

Related Articles