Generate ITF-14 Barcodes in Excel Easily – Step-by-Step Guide

Tags: Excel, ITF-14, manually, formula, VBA

An example how to insert ITF-14 barcode in Excel with StrokeScribe barcode generator.

For more examples including bulk barcode generation, look in the related tutorials.

Requirements

Placing ITF-14 as an Active Document

The method is good when you need a single ITF-14 barcode with manual data entry. This method does not require programming, but it is less customizable.

1. Switch to the Insert tab on the Ribbon and click Object.

Inserting the barcode generator object in Excel as an Active Document

2. Look for the StrokeScribe Document in the list:

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

The barcode generator context menu

ITF-14 Customization

Switch to the Code-specific 2 tab in the barcode properties dialog.

Changing the ITF-14 barcode properties

The ITF-14 generator supports the following properties:

Placing ITF-14 in Excel with formula

1. Open the VBA window (Alt+F11) and create a standard module (VBAProject->Insert->Module). Do not use a worksheet or a workbook module - the formula will not call a function from there.

2. Paste the following code into the module:

Function CreateBarcode(data As String) As String Dim AC As Range Set AC = Excel.Application.Caller Dim wsh As Worksheet Set wsh = AC.Worksheet shname = "barcode_" & AC.Address() On Error Resume Next wsh.Shapes(shname).Delete On Error GoTo 0 bar_w = AC.MergeArea.Width bar_h = AC.MergeArea.Height Dim ss As StrokeScribeClass Set ss = CreateObject("STROKESCRIBE.StrokeScribeClass.1") ss.Alphabet = ITF14 ss.ITF14BearerBox = True ss.ITF14BearerWidth = 1 ss.Text = data image_path = Environ("TEMP") & "\barcode.wmf" rc = ss.SavePicture(image_path, WMF, 1440, 1440 / (bar_w / bar_h)) If rc > 0 Then CreateBarcode = ss.ErrorDescription Exit Function End If Dim shp As Shape Set shp = wsh.Shapes.AddPicture(image_path, msoFalse, msoTrue, AC.Left, AC.Top, bar_w, bar_h) shp.Name = shname Kill image_path CreateBarcode = "" End Function

3. Add a reference to the StrokeScribe Class into your VBA project.

4. Switch back to the Excel window. Choose a cell and type in the formula field:

=CreateBarcode("1234567890123") or =CreateBarcode(A1) Inserting an ITF-14 barcode with formula