Search code examples
excelvbazplbarcode-printing

Printing a barcode trough ZPL code generated and sent by excel-vba


I have read some people managed to print trough DOS and emulating a parallel port trough USB connection and sharing the printer.

The printer in this case is not atached via USB but via LAN cable.

this is the ZPL code I generated for the label:

CT~~CD,~CC^~CT~
^XA~TA000~JSN^LT0^MNW^MTT^PON^PMN^LH0,0^JMA^PR5,5~SD15^JUS^LRN^CI0^XZ

^XA
^MMT
^PW320
^LL0240
^LS0
^BY1,3,131^FT6,180^B3N,N,,N,N
^FD[Barcode_here]^FS
^PQ[quantity to print],0,1,Y^XZ

Where [Barcode_Here] will be the barcode taken from an Excel cell and [quantity to print] will also be the result of some Excel table calculations.

I have read that this needs to be sent to the printer in RAW format and I have read the printer can be set up with passtrough character. I know from the settings that i need to mark my ZPL code with ${ and }$

What I need help with is: how would I go about sending the two parts of the code I have given above to the printer using only Excel vba code so that my project can be self contained and need nothing else?
I need the two parts to be 2 different sends since the first part (from what i understand) is a "setup" code and it would significantly slow down the process if repeated.
Is it even at all possible? (I have seen some people cimenting with something of the sort gave up and wrote a parallel comunication emulation in c++ to solve this).

Thanks for the help, i am unsure if this is considered off topic, if it is so let me know where can i ask for assistence as a comment please.

EDIT: This is an example of people shifting from vba to c++ to solve this issue


Solution

  • Install your Zebra printer on your local Windows using the IP address of your Zebra, by creating a new tcp/ip port. Use the Generic / Text Only drivers.

    Copy/paste your ZPL code to notepad, and print. The ZPL code will be interpreted by the Zebra and generate the corresponding label. There is no set up with passtrough character.

    From your VBA you can create a txt file containing your ZPL code, and print it with notepad.