Skip to content

dython/PrintingLabels

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 

Repository files navigation

PrintingLabels

Enhancing Label Printing Efficiency with VBA

In today's market, a plethora of label printing software offers a combination of GUI design, editing, and printing functions. Notable among these is ZebraDesigner, which often accompanies the printer upon purchase and generally meets many user needs.

However, as is the case with many off-the-shelf solutions, there are instances where they fail to fully address unique operational demands or optimize workflows to the utmost efficiency.

To illustrate, let's delve into a specific challenge I encountered: the necessity to print location-specific labels for a racking system. These labels required directional arrows to indicate their intended placement. For ease of scanning, all labels were designated to be positioned on the 1st level column. A seemingly straightforward approach would be to sort the locations with identical directions, design two distinct formats, and proceed with printing in two separate batches.

The drawback to this method lies in the post-printing phase: each label needs to be individually separated and then re-sorted by location, a process that is time-consuming and prone to errors. An ideal scenario would be to print labels sequentially by location, allowing for immediate use straight from the roll. However, the absence of available software capable of alternating between two label formats based on location sequence presented an obstacle.

This challenge inspired the creation of a VBA solution, which I'm excited to share. By leveraging the flexibility and power of VBA, this code bridges the gap, facilitating the efficient and accurate printing of labels tailored to specific needs.

Printing Method: USB vs. Network

When deciding on a printing method, the two primary options available are USB and Network connections.

USB Connection:

If your printer is connected via USB, you will typically rely on the Windows printer driver. One notable limitation of USB connections is the necessity to have a barcode font installed on your PC. This results in the barcode being printed as a bitmap, which can slow down the printing process and produce a barcode with lower resolution.

Network Connection:

For printers equipped with a LAN port, it's advisable to opt for a network connection. Connecting via LAN offers enhanced flexibility, superior to that of USB in multiple aspects. The primary advantage lies in the speed of printing. Furthermore, a network connection allows the utilization of the printer's built-in fonts, ensuring high-resolution outputs. This is especially beneficial for barcodes, as it yields clearer and more precise scans.

Program Concept: USB Connection

For clarification purposes, imagine we need to create two label formats, each displaying an arrow pointing either left or right at the top. Here are the examples:

Left lable design:
<<<<<<<
[locationBarcode]
[locationName]
Right label design:
>>>>>>>
[locationBarcode]
[locationName]

Prerequisites:

You need to design two distinct labels, each on its separate worksheet in Excel. The design is WYSIWYG (What You See Is What You Get), meaning the labels will look in the printed form exactly how they appear on the screen. This design process allows for using any installed fonts and graphic tools available to you. You will need to install a barcode font to display the barcode on the sheet. Although there are many free barcode fonts available on the web, the recommended one for this purpose is "IDAutomationHC39M". You can download it from this link. https://www.idautomation.com/free-barcode-products/code39-font/

Procedure:

Using VBA (Visual Basic for Applications), the code will fetch the data for the labels. This data also includes directional information for an arrow. After retrieving the data, VBA will update the labels located on the dedicated worksheets. Once the labels are updated with the correct data, they will be sent directly to a printer to be printed out.

Program Concept: Network Connection

Prerequisites:

Before implementing this method, begin by crafting a label design using any available off-the-shelf application. An essential step in this process is to input custom descriptions for each data segment of the label. To illustrate, if your requirements include a location name, a barcode denoting the location, and a directional arrow, two design formats should be created, termed left_label.lbl and right_label.lbl. Here's a representation of what left_label.lbl might look like:

Procedure:

Once your design is ready, produce a printed version to assess its quality. If the design meets your specifications, proceed to print the label to a file. Within the print dialog, select the 'print to file' option. This will generate a file with a distinctive extension, but its core content remains plain text. In my experience using ZebraDesigner, the saved file had a .prn extension. Opening this file with a standard text editor will reveal a mix of unusual characters. However, the data segments can be discerned easily. In above example case, you can find [locationBarcode] and [locationName] in the file. The role of VBA in this setup is to identify and modify these data segments within the file before relaying it to the printer. Most of the remaining content is written in ZPL (Zebra Printer Language), guiding the label's formatting.

A noteworthy aspect of this method is the use of FTP for dispatching the print file. Network printers typically house a rudimentary FTP server. Transmitting a file to this FTP server enables the printer to manage the subsequent steps – both printing the label and deleting the file post-print.

About

Enhancing Label Printing Efficiency with VBA

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published