StrokeScribe header

ITF-14 in Word, Excel, C# and Javascript



Have an opinion?
Quick jump: Word | Excel | C# | IE/JavaScript | Manual settings
This barcode type is based on high-density Interleaved 2 of 5 symbology, which encodes only numeric information.

The black lines around the ITF-14 barcode are called the bearer bars. Some barcodes may have only the top and the bottom lines. Bearer bars provide the printing plate support and minimize the risk of partial scan errors.
ITF-14 codes are typically printed directly on corrugated cartons, cases and pallets.

ITF-14 examples

The purpose of ITF-14 barcode is to encode the Global Trade Item Number:
GTIN-14

This code contains the following information:
1: Package Indicator
2: GS1 country code
3: GS1 Company Prefix
4: Item Reference
5: Check digit

Use one of following codes for the Package Indicator:
0. Case or carton
1. Pallet
2. Container
3. Undefined
4. Internal company use
5-8. Reserved
9. Used to identify random weight products


How to put a single ITF-14 barcode into Microsoft Word document

This example places an ITF-14 barcode into Microsoft Word document at current text input position.

ITF-14 in Word document

If you hate VBA or want to manually place a single ITF-14 into Word document, see instructions how to create bar code in Word 2007 and Word 2010, and then see how to change the object properties to produce ITF-14 bar code.

This barcode will have user-defined bearer box width. To draw the barcode with top and bottom bearer bars only, set ITF14BearerBox to false. For full property list, visit documentation page.


    Dim shape As InlineShape
    Dim ss As StrokeScribe
    Set shape = Selection.InlineShapes.AddOLEControl _
        ("STROKESCRIBE.StrokeScribeCtrl.1")
    Set ss = shape.OLEFormat.Object
    shape.Width = 200
    shape.Height = 50
    ss.Text = "1234567890123"
    ss.Alphabet = ITF14
    ss.ITF14BearerBox = True
    ss.ITF14BearerWidth = 10
Remember to add a reference to StrokeScribe ActiveX control.

How to create multiple ITF-14 codes in Microsoft Word using data from a text file

Before running this sample code, prepare a text file which will be the data source for a series of ITF-14 bar codes. The file must look like this:


1234567891231
1234567891222
1234567891213

Specify your file name in the second line of code ("c:\data.txt" is by default).

Because the Shapes collection is used (instead of InlineShapes) to create barcode objects, these barcodes will float above the document content and could be placed at any position on the document page.


ypos = 1 'The vertical position of created barcode object
Open "c:\data.txt" For Input As #1
While Not EOF(1) 
   Input #1, txt  'Read the text file line-by-line

   Dim sh As Shape
   Dim ss As StrokeScribe
   Set sh = ActiveSheet.Shapes.AddOLEObject _
       (ClassType:="STROKESCRIBE.StrokeScribeCtrl.1")
   
   sh.LockAspectRatio = msoFalse
   sh.Left = InchesToPoints(1)
   sh.Top = InchesToPoints(ypos)
   sh.Width = InchesToPoints(3)
   sh.Height = InchesToPoints(0.5)
   
   Set ss = sh.OLEFormat.Object
   ss.Alphabet = ITF14
   ss.Text = txt
   
   ypos = ypos + 1 'Next barcode will be placed one inch lower than the current object
Wend
Close #1

Remember to add a reference to StrokeScribe ActiveX control.

See how to delete previously created barcodes.

If you are looking for a code solution for reading barcode data from USB/RS-232 scanner in Microsoft Word, try to read serial data with StrokeReader ActiveX.



How to create ITF-14 in Microsoft Excel using data from worksheet cells

This example needs you to know VBA. If you want to manually place a single ITF-14 into Excel worksheet, see instructions how to do it in Excel 2007 and Excel 2010, and then see how to change the object properties to produce ITF-14 bar code.

Fill some cells of the first column with 13-digit numbers. These cells will be used as the source for a series of ITF-14 bar codes.
Excel table data for ITF-14

This code will read cells of the first column until the first empty cell is found.


    Row = 1 'Start from the first cell in the row
    Dim sh As Shape
    Dim ss As StrokeScribe
    
    Do
       Dim data As String
       data = ActiveSheet.Cells(Row, 1) 'Read cells (1, 1), (2, 1), (3, 1)...
       If Len(data) = 0 Then 'Exit if an empty cell found
          Exit Do
       End If
    
       Set sh = ActiveSheet.Shapes.AddOLEObject _
        (ClassType:="STROKESCRIBE.StrokeScribeCtrl.1", _
         Left:=50, Top:=50 * Row, Width:=300, Height:=50)

       Set ss = sh.OLEFormat.Object.Object
       ss.Alphabet = ITF14
       ss.Text = data 'Encode the cell data in the barcode
       
       Row = Row + 1 'Go to the next cell in the row
    Loop

Remember to add a reference to StrokeScribe ActiveX control.

To delete all created barcodes, see this example.

If you are looking for a code solution for reading barcode data from USB/RS-232 scanner in Excel, try to read serial data with StrokeReader.




How to create ITF-14 from C# application

This example will save an ITF-14 barcode image in .BMP file. Additionally, you can save ITF-14 as JPG, GIF or PNG image with commercial versions of StrokeScribe.

See more details about creating bar codes in C# applications and console services in c# barcoding examples.


using STROKESCRIBECLSLib;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StrokeScribeClass ss;
            ss = new StrokeScribeClass();
            ss.Alphabet = enumAlphabet.ITF14;
            ss.Text = "1234567890123";
            int rc = ss.SavePicture("c:\\barcode.bmp", enumFormats.BMP, 400, 200);
            if (rc != 0)
               System.Console.Write("operation is unsuccessful");
        }
    }
}

Remember to add a reference to StrokeScribe class in your C# project.




ITF-14 bar code in Internet Explorer/JavaScript

An example how to create an ITF-14 code on html page and modify it's properties from JavaScript.
This example is intended to run only in Internet Explorer because it depends on ActiveX support which is only available in IE. To run this example, copy the code into .hta file instead of .htm - this will disable numerous security warnings displayed by Internet Explorer.


<head> 
  <script>
  function SetBarcode() 
  { 
    var barcode = document.getElementById("BarCode");
    barcode.Text = "3001234567891";
    barcode.Alphabet = "7"; //ITF-14
    barcode.ITF14BearerBox = "true";
  }
  </script>
</head>

<body>
  <button onclick="javascript:SetBarcode()">Start</button>

  <object classid="CLSID:7E42B8C5-73BE-4806-8904-FF4080A6960C" id="BarCode"	
    style="position: absolute; width: 30mm; height: 80mm; 
           left: 20mm; top: 20mm;">
	<param name="Rotation" value="270"/>
	<param name="Alphabet" value="7"/>
	<param name="Text" value="1234123412345"/>

  </object>
</body>
</html>

If you are looking for a code solution for reading barcode data from USB/RS-232 scanner in IE/JavaScript, try our StrokeReader serial interface ActiveX control.




Manual ITF-14 property setting

See guides for AutoCAD 2010, Word 2010 and Excel 2010 to learn how to manually insert barcodes of any format in these applications. For other software, the process of barcode integration is more or less the same.

Double-click on the inserted barcode object or right-click on it and choose Properties from the context menu or click on StrokeScribe Control Object in the context menu.
Barcode object context menu

Select ITF-14 from the Alphabet field and enter some data to be encoded as shown on the picture. ITF-14 barcodes always encode 14 digits. This ActiveX can automatically calculate the check digit if only first 13 digits are entered into the Text field.
ITF-14 properties

Open the Code-specific tab to set the bearer bar properties.
Barcode-specific properties

If you are not familiar with ActiveX manipulation in your software, please check our example list in the web site navigation menu.