Solved

how to get rid of the blank label after printing

Posted on 2014-11-29
12
280 Views
Last Modified: 2014-12-10
Hello Experts,
We are trying to print labels from an old application still working.
We used vb6 and vfp9, to develop a very small routine,
but both modules after printing always print a blank label.
How can we stop this blank label from being printed ??
Regards!
0
Comment
Question by:rguillermo
  • 6
  • 3
  • 2
12 Comments
 
LVL 46

Expert Comment

by:Martin Liss
ID: 40472211
Can you post the VB6 routine that you are using?
0
 

Author Comment

by:rguillermo
ID: 40472214
Martin Liss,
Here you have my code in vb6

Private Sub Command1_Click()
   Snippet
End Sub

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

Open in new window



'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 = 1
            .Font = "Code 128"
            .FontSize = 38
            .FontBold = False
            .FontItalic = False
            .CurrentX = 1.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 Comment

by:rguillermo
ID: 40472220
Attached is the Project in rar file
BARCODE.vbw
BARCODE.frm
BARCODE.vbp
0
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 40472226
Could it be that you are trying to print too much on the label and the Printer.Print Space(1) line causes it to overflow onto the next label. To test that you could either comment out the line or change it to something like Printer.Print "overflow?".
0
 

Author Comment

by:rguillermo
ID: 40472276
I just tried only printing the bar code that is half the size of the label,
even then the printers makes another blank label.
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.

 

Author Comment

by:rguillermo
ID: 40472279
I discovered the

.enddoc

line closes the printing and causes the printer  to feed one more label in blank.

Is there something that can be done with this particular line in order to stop it from advancing one more blank label each time I finish printing a label?
0
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 250 total points
ID: 40472527
Try this before the enddoc.

.CurrentY = 0

BTW in you're existing code you have .CurrentY = -0.15 which is strange. Why isn't that just zero?
0
 
LVL 18

Accepted Solution

by:
Simon earned 250 total points
ID: 40472766
From memory, I think the .CurrentY =-0.15 was to get the barcode to print at max font size and still fit all the label data on the page height. It was because we didn't need the full height of the barcode at that font size but did want the width for maximum readability by the barcode scanners.
We didn't have an issue with blank labels being printed (using Zebra TLP2824 and TLP2824Z printers), but you're using a different model, probably with different media size. For example, we knew that with the field lengths we had, none of the printer would overflow the page width using that fixed width font size.
I did hack down the code drastically to provide the example. I'd suggest setting .CurrentY =0 and reducing the barcode font size while you're testing, to ensure that isn't causing the page-throw, and also appending ";" to your last Printer.print statement to suppress the last linebreak e.g.
.print "syx";
.enddoc
End With

Open in new window


If that doesn't work, i suggest you comment out all label printing lines except the barcode to start with and see if the problem persists, and then add one line of print at a time until you find where it causes a problem.
0
 

Author Comment

by:rguillermo
ID: 40484399
Here is my latest code, still getting the blank label at the end,
SimonAdept, I tried testing each line separeately but all cause the blank label agter printing.

Please all I need is not to have that blank label at then end.....

Here is my latest code:

Private Sub Command1_Click()
   Snippet
End Sub

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()
  Dim X As Integer
'Label_WithBarcode:
        'If bPrintBarcode = True Then
  Open "c:\tmp\barcode_label.CSV" For Input As #1 Len = 60
  Input #1, w1, w2, w3, w4, w5, w6
  Input #1, w1, w2, w3, w4, w5, w6
  w_pro_cod = Trim(w1)
  w_bar_cod = Trim(w2)
  w_pro_des = Trim(w3)
  w_uni_pri = Trim(w4)
  w_exp_dat = Trim(w5)
  w_qty = Trim(w6)
  Close #1
           
            X = 2
            With Printer
           
            .ScaleMode = vbCentimeters
            .Orientation = 1
            .Font = "Code 128"
            .FontSize = 30
            .FontBold = False
            .FontItalic = False
            .CurrentX = 2.4
            .CurrentY = 0.3
             Printer.Print w_bar_cod
           
            .Font = "Arial Narrow"
            .FontSize = 11
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 0
            Printer.Print "Botica Paradera"
           
            .Font = "Arial Narrow"
            .FontSize = 14
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.3
            Printer.Print Space(8) & "F." & w_uni_pri;
           
            .Font = "Arial Narrow"
            .FontSize = 6
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.4
            Printer.Print w_exp_dat
           
            .Font = "Arial Narrow"
            .FontSize = 8
            .FontBold = True
            .FontItalic = False
            .CurrentX = X
            .CurrentY = 1.8
            Printer.Print w_pro_des
           
            .EndDoc
         End With
End Sub
0
 
LVL 18

Assisted Solution

by:Simon
Simon earned 250 total points
ID: 40484491
Hi,

Did you try Martin's suggestion of setting CurrentY to zero before the .enddoc line?

The other questions I need to ask are:
Do you get a blank label (form feed) after printing to the printer by other methods  - e.g. just printing a single word text document to the printer?
Have you tried printing just a simple text string (no barcode) using the above code?

If you still get blank labels after testing the above items, I'd look at the printing preferences/defaults of the Zebra printer and get it to print its config sheet - usually by holding down the form-feed button until it flashes once or twice (you'd have to check the manual for your model if it's different).
0
 

Author Comment

by:rguillermo
ID: 40491222
Yes I did try Martins suggestion, but still the ".enddoc" statement still releases one more blank label after finishing,
We migrated the whole source I sent you to visual basci 2013, its working fine now and problem solved.

Thank you Experts for all your effort and opinión they were ery useful to us in order to finish our testing and decide what to do.

Best regards!
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

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

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

12 Experts available now in Live!

Get 1:1 Help Now