Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use BarOne Lite from Zebra.com to create ZPL

Print ZPL from VB or VBA

Use BarOne Lite from Zebra.com to create ZPL

by  DougP  Posted    (Edited  )
Get a copy of "Zebra Designer Pro" from Zebra (they donÆt make Bar ONE Lite anymore) http://www.zebra.com/SD/demos.htm
Install the software as normal.
Note the DEMO will substitute letters like "Z" for "e" every occurrence it finds in the label. Just change it back to what it is supposed to be.

Open the software and choose the Zebra Printer from the list. If this is for a T402 or whatever.

When you print there is a check box on the popup box left side ôPrint to fileö check it and it will prompt for a file name. I use C:\test.txt so I can find it easily and open it in Notepad by default.

Create a label the with special Words for each field where the data changes. In other words if you type 12345 in every box in the label design, it's hard to find which 12345 is for which item of data.
Example: For Quantity barcode key in BARQTY- for the fixed text. This will be easy to spot on the jumble of ZPL created later.
Note choose native Zebra fonts for normal text they are at the very bottom of the fonts list. Only 2 or 3 of them work in the demo. If you use a true type font you will get reams of HEX the program changed the whole thing to a Graphic image.

When you print there is a check box on the popup box ôPrint to fileö check it and it will prompt for a file name, Key in [red] c:\Mylabel.txt [/red] or something easily found.
Next go into Windows Explorer and double click this file name, it will open in Notepad.
Looking like so:
A&Z AEX0Z A %0 H054 V0489 B103099*BARQTY-* %0 H061 V0694 B103099*BARSPLR-* %0 H056 V0068 B103099*BARPO123-* %0 H054 V0889 B103099*BARPKGID1-* %0 H0 à
If you see pages and pages of HEX code itÆs because you chose a TRUE TYPE font which the software changed to a graphic. Go back to the label design and look at each normal text and change it to a Zebra native Text font. Then try again.
You can see the ZPL code generated.
Now to test it and make sure it prints:
Go to a command prompt and key in the following:
Copy c:\Mylabel.txt LPT1: 'this only work on non USB printer interfaces
Where LPT1: is the port of the actual Zebra Printer
If it is on a network share then use this
Copy c:\Mylabel.txt \\ServerName\Sharename
In one company I used this
copy aiag10.txt \\Smallbserver\SATOCL608

Next I paste this ZPL code from c:\Mylabel.txt into my program.

Then I replace the BARQTY- with this code for Visual Basic or VBA
& Me!Qty &
This allows the data on my form to control what goes in the barcode label.
Code:
Private Sub Command13_Click()
        Dim labeltoPrint, BatFile As String
        labeltoPrint = "C:\ReelLabel.txt"
        BatFile = "C:\PrintReelLabel.bat"

            Open labeltoPrint For Output As #1
                Print #1, "Q305,019"
                Print #1, "B29,102,0,1,2,6,41,B," & Chr(34) & Me!txtDateCode & Chr(34)
                Print #1, "A29,88,0,1,1,1,N," & Chr(34) & "DateCode" & Chr(34)
                Print #1, "B243,229,0,1,2,6,41,B," & Chr(34) & Me!Barcode & Chr(34)
                Print #1, "A388,166,0,2,1,2,N," & Chr(34) & "Ko Depth = " & Me!DDIM 
                Print #1, "A631,11,0,1,1,1,N," & Chr$(34) & "Serial#" & Chr(34)
                Print #1, "A29,16,0,1,1,1,N," & Chr$(34) & "PartNumber" & Chr(34)
                Print #1, "A29,31,0,2,3,3,N," & Chr$(34) & Me.ProductName & Chr(34)
                Print #1, "B631,26,0,2,2,6,37,B," & Chr$(34) & Me.txtSerial & Chr(34)
                Print #1, "A29,31,0,2,3,2,N" & Chr$(34) & "Barcode" & Chr$(34)
                Print #1, "A654,113,0,1,1,1,N," & Chr$(34) & "Bin" & Chr$(34)
                Print #1, "A656,128,0,2,2,2,N," & Chr$(34) & Me.Bin & Chr$(34)
                Print #1, "P1"  ænote number of labels to print put P3 and you get 3 labels
            Close #1
            
            Dim retval
            ' debug.print BatFile
            retval = Shell(BatFile, vbMinimizedFocus)

'Note the above ZPL is shortened to get it in the FAQ

C:\PrintReelLabel.bat Batfile = this one liner
Code:
Copy C:\ReelLabel.txt LPT1:
pause

Note: the pause statement is for trouble shooting. Sometimes the file name is incorrect or the printer share name is not right, nothing happens. When it pause's it will also print out any errors it encountered. If not it will say file xxx transferred correctly, or something to that effect.
take the pause out when it works.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top