Barcode macros

Sample macros for creating font barcodes in Access, Excel and Word are included for Microsoft Office version 2000, 2003 and 2007. The elements of the macros is discussed using the Excel 2000 version as an example. The Word macros are described in the Word documents that demonstrate the macros, and the Access macros may be examined by opening the sample access databases included.

Sample macros for converting data into barcode characters are provided in the Excel spreadsheet sample (dfx2k.xls is the Excel 2000 version; other versions may be included in the dFont/excel directory). The source code for the macros (Barcode and BarcodeSetup) are accessible and can be modified by an experienced Excel user. The macros calls the dFont DLL, so this DLL must be accessible to Excel.

The BarcodeSetup macro displays a dialog box enabling the properties required for the barcode (such as barcode type, whether an automatic check digit is required, and the barcode font to be used). Once set, the barcode properties will remain as defaults until change by running the BarcodeSetup macro again.

The Barcode macro is used as follows:

a)  Select the column on the right of the cells containing the barcode data and format the cells to hold text – by selecting the Text item in the dialog that appears when the Format – Cells – Number menu item is chosen

b)  Select a range of cells in a single column containing the barcode data

c)  Select Barcode from the Tools – Macro – Macros menu

d)  A dialog box appears requesting details of the barcode type required (this may be prevented and the barcode details hard-coded by editing the macro)

e)  The macro takes data from each cell in turn and places the barcode text in the adjacent cell. Processing is terminated at the end of the selection or the first blank cell.

f)   Select the column containing the new barcode text and set its font to the required barcode font – by selecting the font (an size) in the dialog that appears when the Format – Cells – Font menu item is chosen. Also centre the text in this column and set the column width to ensure that the barcodes are at least 5 mm clear of the gridlines. If the same font will always be used these steps may be incorporated into the macro.

g)  Select all rows containing a barcode and set the Row Height to the required value.

The spreadsheet containing the barcode should now be printable.

More:

Installation of macros in another spreadsheet