In this Excel barcode generator user guide, you will learn how to create, update linear, 2d barcodes through Excel Macro programming or VBA script codes in your Excel
document.
- Easy to update all barcodes in Excel document through Excel VBA script codes
- Update barcodes with updated Excel cell datas
- No font, COM control, VBA, Macro, activex programming code installed
This example demonstrates how to update those exist "link-to-cell" barcodes in the workbook by using VBA (Visual Basic for Applications) code.
Prepare a sample Excel document with list of barcode already generated. You can view the detailed guide here:
How to create bulk/multiple barcodes from Excel Cell datas in Excel document?
Step 1: Open prepared Excel file "EAN-13-Data-Sample-Report.xlsx".
Step 2: Open Excel Developer tool "Microsoft Visual Basic for Applications"
On the Excel Ribbon, click the
Developer tab.
Then, click
Visual Basic in the Code group to open the "Microsoft Visual Basic for Applications" window
Step 3: Open file "ThisWorkbook" to add VBA script code
Double-click
ThisWorkbook in the Project window to open the code file.
Step 4: Add sample VBA code to update barcodes in Excel
Copy all following VB code to the code file.
- Create a new Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn") object
- Call method UpdateAllBarcode to update all barcodes in the Excel document
Sub CallVSTOMethod()
' Update contents of those cells in the Number column
Sheet1.Range("B4").Value = "1234567890123"
Sheet1.Range("B5").Value = "1234567890345"
Sheet1.Range("B6").Value = "1234567890567"
Sheet1.Range("B7").Value = "1234567890789"
' Get a COMAddIn object that represents the OnBarcode.OnBarcodeExcelAddIn VSTO Add-in.
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("OnBarcode.OnBarcodeExcelAddIn")
' Get the Object property of the COMAddIn and call the UpdateAllBarcode method.
Set automationObject = addIn.Object
automationObject.UpdateAllBarcode
End Sub
Step 5: Run the VBA code to update all barcodes in Excel document
Press F5 to run the code.
Then, four cells in the Number column have been updated to new values, and four linked Pictures (in Barcode column) have been refreshed by method UpdateAllBarcode.