PDF417 barcode in Excel

PDF417 in Excel With Formula

Table of Contents

An example how to use COM-class version of StrokeScribe barcode generator in a cell formula to make PDF417 barcodes in Excel. This example requires good VBA knowledge.

The barcode updates automatically when the formula is evaluated.

Setup

A formula-based example of making PDF417 in Excel

In Excel, open VBA window (Alt+F11) and create a standard module (VBAProject->Insert->Module). Do not use a workbook or a worksheet module - the cell formula cannot call VBA code from these module types.

Copy 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 ' Returns the cell width. WOrks both with merged and single cells. bar_h = AC.MergeArea.Height Dim ss As StrokeScribeClass Set ss = CreateObject("STROKESCRIBE.StrokeScribeClass.1") ss.Alphabet = PDF417 ss.Text = data image_path = Environ("TEMP") & "\pdf417.wmf" ' We need a temporary file to store the barcode picture. 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

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

Switch back to the Excel window.

Choose a cell and type in the formula field:

=CreateBarcode("Some text to encode in the PDF417")
Facebook X Bluesky Youtube Contacts

© 2026 StrokeScribe. All rights reserved. Use of any portion of this site constitutes acceptance of our Terms of Use and Privacy Policy. The website material may not be reproduced, except with the prior written permission.