FAQ: TBarCode Office Excel Add-In
How Can I Auto-Update the Barcodes Once a Cell Is Changed?
How Can I Auto-Update the Barcodes Once a Cell Is Changed?
With EMF barcodes, the barcodes are updated during printing and on saving the document. If you need to update the barcodes immediately when a specific cell or range has been changed, you can do that with a macro:
- Enable „Refresh barcodes on save“ in the add-in options.
- Add the following code to your Excel sheet (ALT-F11) and save it as macro enabled workbook.
Private Sub Worksheet_Change(ByVal Target As Range)
' specify the range, which will trigger the auto-save here
If (InRange(Target, Range("A1:A10"))) Then
Application.DisplayStatusBar = True
Application.ActiveWorkbook.Save
Application.StatusBar = "Auto-Save done!"
End If
End SubFunction InRange(Range1 As Range, Range2 As Range) As Boolean
InRange = Not (Application.Intersect(Range1, Range2) Is Nothing)
End Function
The macro will save the document and this will trigger the bar code update.
Excel disables macros (or event driven macros) in Design mode. Because the TBarCode Panel switches to Design mode for editing objects, you have to close the TBarCode Panel for enabling the macro.