Generate Code 128 barcodes

How to generate Code128 Barcode in MS Excel spreadsheet

This implementation configures dynamic code 128 barcode encoding within spreadsheets by **registering the COM DLL interface** (cruflbcs_x64.dll for 64-bit systems or cruflbcs.dll for 32-bit environments) through an elevated command prompt. After **enabling all macros** inside the Excel Trust Center, open the VBA Editor using ALT + F11 to **bind the crUFLBcs Type Library reference** and import the barcodesoft.bas module. Data streams are then instantly converted using **native column formulas** like =Code128B(A1) and rendered visually by assigning the specialized Code128mHr barcode font typeface.

Step 1. Right click command prompt and run command prompt as administrator.

code 128 command prompt as administrator
To register 64-bit DLL, please type in the following commands:
cd "C:\Program Files\Common Files\Barcodesoft\FontUtil"
%systemroot%\System32\regsvr32.exe cruflbcs_x64.dll
Type in the following commands to register cruflbcs.dll
cd "C:\Program Files (x86)\Common Files\Barcodesoft\FontUtil"
regsvr32.exe cruflbcs.dll
register cruflbcs.dll commands for code 128
If you see the following Window pop up, your registration was successful.
register cruflbcs.dll succeeded

Step 2. Start Microsoft® Excel®. If you are using Excel 2000 or 2003, click menu ===> Tools ==> Macro ===> Security. Choose Low security level.

Code128 Macro Security
If you are using Excel 2010 / 2013 / 2016 / 2019 / 2021 / 2024, click the Microsoft Office Button.
Office 2010 button Office 2016 button Office 2019 button
Then click Excel Options, choose Trust Center. In the Macro Settings category, under Macro Settings, choose "Enable all macros" as shown below.
Code128 Macro Setting

Step 3. Press ALT + F11 to open Microsoft® Visual Basic editor.

Code128 VBA

Step 4. From Visual Basic editor, choose menu Tools ===> References. It will popup a dialog. Click Browse button and choose cruflbcs.dll from your working folder. Usually it's under C:\Program Files (x86)\Common Files\Barcodesoft\Fontutil folder. Click the checkbox beside crUFLBcs 1.0 Type Library as shown below. Then click OK button.

Code128 add reference

Step 5. Press Ctrl+M, it will popup a dialog, choose barcodesoft.bas under C:\Program Files (x86)\Common Files\Barcodesoft\Fontutil folder. Then click "Open". If you don't find barcodesoft.bas, please download it from Code128.

Code128 import vba

Step 6. Close Visual Basic editor and go back to your spreadsheet. Now, you can use the following macros to encode data: Code128 . When you have lots of data to process, you can just copy and paste the macro to the whole column and all data will be encoded immediately.
=Code128A(xxx) =Code128B(xxx) =Code128C(xxx) Please use cell reference to replace xxx in the formulas as shown below.

Code128 barcod excel macro

Step 7. Right click Cell B1, choose Format Cell from context menu. Then click Font to apply one of the appropriate font typefaces to the cell, such as Code128mHr.

Code128 import vba