Solved

print labels to a Zebra printer from my app

Posted on 2014-11-22
7
584 Views
Last Modified: 2014-11-25
Hello Experts,
We got this ZEBRA GC420t printer at the office, now we need to print labels from our application.

The printer works just fine with its own software, but we have to type all we need per label each time.

the idea is to put a button in the product window of our app and just by clicking once: the right label with the right data will be printed as many times as specified.

Please all ideas are welcome, if you have source that we can adjust or take as model will be great,

Regards!
0
Comment
Question by:rguillermo
7 Comments
 
LVL 18

Expert Comment

by:Simon
ID: 40460107
Isn't it just a case of selecting the Zebra printer (if it's not already the default printer) and issuing the print command?

I do have some old VB6 code for printing to Zebra printers that builds the print line by line, but I can't access it until Monday.

Are you printing just text, or barcodes, graphics etc?
0
 

Author Comment

by:rguillermo
ID: 40460224
SimonAdept,
yes if posible please send me one or two examples of that vb6 source
I am willing to print text bar code and graphic all toguether
0
 
LVL 18

Expert Comment

by:Simon
ID: 40460519
OK, but I can't get to it for another 24 hours. Happy for someone else to chip in and answer this if they can do so sooner.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 12

Expert Comment

by:ktaczala
ID: 40460561
You will need to get the programming manual for the printer. Zebra Printers have their own codes for formatting barcodes, fonts, etc.

I did some years ago with a powerbuilder inventory app.
0
 
LVL 6

Expert Comment

by:tncode
ID: 40460855
A font may be easier to use unless you know the printer's own language. Some companies make barcode fonts that work well on thermal printers at certain point sizes.
0
 
LVL 18

Accepted Solution

by:
Simon earned 500 total points
ID: 40462076
A lot of the Zebra printers have built-in barcode fonts, not sure about your specific model.

Here is the VB6 code:
Private Sub Form_Load()
For i = 0 To Printers.Count - 1
' if the specified printer is found select it
    If InStr(UCase(Printers(i).DeviceName), "ZEBRA") > 0 Then
        Set Printer = Printers(i)
        SelectPrinter = True
        Exit For
    End If
Next i
If Not SelectPrinter Then
    MsgBox "Unable to find Zebra printer ", vbOKOnly + vbExclamation, " Error"
    End
End If

'Check Code 128 Barcode Font is installed.
Dim bCompare As Boolean
Dim strFont As String

strFont = "Code 128"
For i = 0 To Screen.FontCount - 1
 If Screen.Fonts(i) = "Code 128" Then strScreenFont = "Code 128"
Next

bCompare = StrComp(strFont, strScreenFont, vbTextCompare) = 0

If Not (bCompare) Then
    MsgBox "Barcode font not installed. Reverting to printing non-barcode label.", vbInformation, "Barcode Font Not Installed!"
    bPrintBarcode = False
Else
    'Barcode font installed
    bPrintBarcode = True
End If
End Sub


Snippet from the printing routine that demonstrates switching font from barcode to courier font...

Sub Snippet()

Label_WithBarcode:
        If bPrintBarcode = True Then
            With Printer
            .ScaleMode = vbCentimeters
            .Orientation = 2
            .Font = "Code 128"
            .FontSize = 38
            .FontBold = False
            .FontItalic = False
            .CurrentX = 4.2
            .CurrentY = -0.15
         
            Printer.Print "19293929"
            .Font = "Courier New"
            .FontSize = 11
            .FontBold = True
            .FontItalic = False
            .CurrentX = 0
            .CurrentY = 0.3
            Printer.Print Space(4) & "19293929"

            .CurrentX = 0
            .CurrentY = 1.15
            .FontSize = 15
            Printer.Print Space(1) & StrConv(Surname, vbUpperCase)

            .FontSize = 11
            .CurrentY = 1.6
            Printer.Print Space(17) & StrConv(Forenames, vbUpperCase)
            
            Printer.Print " DofB: " & "13/2/2011" & Space(5) & "Gender : " & "(" & "Male" & ")"

            .FontSize = 5
            Printer.Print Space(1)
            .FontSize = 11

            End If
            .EndDoc
            End With
        End If

End Sub

Open in new window

0
 

Author Closing Comment

by:rguillermo
ID: 40466101
Thanks a lot to all Experts!!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now