Last active
October 13, 2016 21:09
-
-
Save larsschenk/8bf190f1966f7b57cacef7904109935c to your computer and use it in GitHub Desktop.
Create Barcodes from an Excel List with www.ActiveBarcode.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Public Sub Create_Barcodes() | |
' Copyright (c) by Schenk & Horn, www.activebarcode.com, www.activebarcode.de | |
ScreenUpdating = False | |
' Column the data is stored | |
DataColumn = "B" | |
' Number of Row the data begins | |
DataRow = 1 | |
' Number of Column the barcodes shall be placed | |
BarcodeColumn = "A" | |
i = DataRow | |
continue = True | |
While continue | |
' CurrentCell | |
DataCell = DataColumn & i | |
CurrentCell = BarcodeColumn & i | |
' Get Size of cell | |
MyHeight = Range(CurrentCell).Height | |
MyWidth = Range(CurrentCell).Width | |
MyTop = Range(CurrentCell).Top | |
MyLeft = Range(CurrentCell).Left | |
' Place the barcode control exactly into a cell | |
ActiveSheet.OLEObjects.Add(ClassType:="BARCODE.BarcodeCtrl.1", Link:=False _ | |
, DisplayAsIcon:=False, Width:=MyWidth, Height:=MyHeight, Top:=MyTop, Left:=MyLeft).Select | |
BarcodeName = ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Name | |
' Set Barcode properties | |
ActiveSheet.OLEObjects(BarcodeName).Object.ShowText = False | |
ActiveSheet.OLEObjects(BarcodeName).Object.Font.Size = 8 | |
ActiveSheet.OLEObjects(BarcodeName).Object.Borderwidth = 5 | |
ActiveSheet.OLEObjects(BarcodeName).Object.Borderheight = 5 | |
ActiveSheet.OLEObjects(BarcodeName).Object.Type = 87 ' CODEGS1DATAMATRIX22X22 | |
' set Barcode text | |
ActiveSheet.OLEObjects(BarcodeName).Object.Text = Range(DataCell) | |
' next data if available | |
continue = Len(Range(DataColumn & i + 1)) > 11 | |
i = i + 1 | |
Wend | |
ScreenUpdating = True | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment