
Barcode in Microsoft Word
Here are some examples how to create barcodes in Word using different versions (ActiveX/COM Class) of the StrokeScribe barcode generator.
Requirements
- Download and install the barcode generator.
Placing a Barcode in Word using Active Document
1. Switch to the Insert tab of the Ribbon and click Object.

2. Look for the StrokeScribe Document:

3. Right-click the barcode object and select StrokeScribe Control Object->Properties from the context menu:

4. Select the desired barcode type and enter some text to encode in the barcode as shown on the picture:

You can use our barcode add-in (works with Word 2007+) to automate the above steps.
Making a Floating Barcode
To make a floating barcode, right-click the barcode and look for the:
- Format Control - in Word XP, 2007-2013
- Format AutoShape/Picture - in Word 2016+

Then, go to the Layout tab on the Word Ribbon and select your preferred text wrapping style:

Placing a Barcode in Word using ActiveX
1. Switch to the Developer tab, click Insert->More Controls as shown on the picture:

2. Select StrokeScribe control from the list of available objects and press OK:

3. Activate the Design Mode button on the Developer tab. Right-click the barcode object, select Properties:

4. Adjust any barcode properties you need.

How to Modify the Barcode Properties in Word with VBA
1. Paste a barcode object into your document as shown here.
2. Press Alt+F11 to open VBA editor. Double-click the ThisDocument item from the VBA project tree as shown on the picture:

3. Paste the following code into the VBA editor:
Sub CreateBarcode()
StrokeScribe1.Alphabet = QRCODE
StrokeScribe1.Text = "123ABCD"
End Sub
4. Place the caret into the Sub body and press F5 to run the code. Switch back to the Word window to see the updated barcode.
Related Tutorials
- Barcode Generation in Microsoft Word with StrokeScribe Class
- QR Code in Microsoft Word
- How To Modify, Move And Resize Barcode In Word with VBA
- Font-based barcode printing in Word
Code Snippets by Barcode Type
Below we show code snippets that work with the VBA-based example. The snippets also work with the manually placed ActiveX - you will need to replace all barcode.xxx statements with StrokeScribe1.xxx. Your ActiveX object may be named differently (i.e. StrokeScribe123). You can find the object's name in the property sheet.
All Barcode Types
How to Encode a Byte Array
barcode.Alphabet = QRCODE
barcode.CodePage = -1
Dim b(1 To 3) As Byte
b(1) = &H11
b(2) = &H22
b(3) = &H33
barcode.Text = b
An example of QR Code with binary data:


EAN-13/UPC-A
To create EAN-13 barcode, modify your code in the following way:
barcode.Alphabet = EAN13
barcode.Text = "123123456780"
The barcode generator checks 13-digit strings to have a correct check digit. For 12-digit values, the check digits are automatically calculated.
UPC-A
When printing UPC-A barcodes, specify 11- or 12-digit string in the Text field. The barcode generator automatically calculates checksums for 11-digit strings.
barcode.Alphabet = UPCA
barcode.Text = "12345678901"
GS1 Country Codes
A list of country codes for use in EAN-13/GS1-128/GS1-DATAMATRIX.

CODE 128
To create a CODE 128 barcode, modify your code in the following way:
barcode.Alphabet = CODE128
barcode.Text = "ANY TEXT"
How to Encode ASCII Control Characters in Code 128
barcode.Alphabet = CODE128
barcode.Text = "ABC" & Chr(9) & "DEF" ' a TAB character
Another way is to use tilde sequences:
barcode.Alphabet = CODE128
barcode.ProcessTilde = True
barcode.Text = "123~x0a~x0d" ' <CR><LF>

PDF417
To create a PDF417 barcode, modify your code in the following way:
barcode.Alphabet = PDF417
barcode.Text = "123ABC"
To create a Compact PDF417:
barcode.Alphabet = PDF417
barcode.CompactPDF417 = True
How to Set Non-default Error Correction Level
barcode.Alphabet = PDF417
barcode.PDF417ErrLevel = 8
How to Fix the Number of Rows or Columns
barcode.Alphabet = PDF417
barcode.PDF417Cols = 3
barcode.PDF417Rows = 7

QR CODE
To create a QR CODE, modify your code in the following way:
barcode.Alphabet = QRCODE
barcode.Text = "123ABCD"
Mobile-friendly Barcodes
Use UTF-8 encoding to make barcodes with national characters readable by mobile barcode readers.
barcode.Alphabet = QRCODE
barcode.CodePage = 65001 ' 65001 = UTF-8
barcode.Text = "ΞΟΠΡΣΤΥΦ"
An example of mobile-readable QR Code that contains UNICODE characters:

How to Modify the Error Correction Level
barcode.Alphabet = QRCODE
barcode.QrECL = H ' L or M or Q or H
How to Force the Minimum Matrix Size
barcode.Alphabet = QRCODE
barcode.QrMinVersion = 11

AZTEC
To create an Aztec barcode, modify your code in the following way:
barcode.Alphabet = AZTEC
barcode.Text = "ABCD123"
How to Force the Minimum Matrix Size
barcode.AztecMinLayers = 132
How to Set the Desired Error Correction Level
barcode.AztecECL = 50
How to Modify the Quiet Zone Size
barcode.QuietZone2D = 0

DATA MATRIX
To create a Data Matrix barcode, modify your code in the following way:
barcode.Alphabet = DATAMATRIX
barcode.Text = "ABC1234"
How to Force the Minimum Matrix Size
barcode.DataMatrixMinSize = 132
How to Modify the Quiet Zone Size
barcode.QuietZone2D = 0
ECI
Use the Extended Channel Interpretation codes ONLY if the receiving party asked you to do so. NEVER use ECI in smartphone readable barcodes.
barcode.ECI = 5;