Solved

how to get rid of the blank label after printing

Posted on 2014-11-29
12
297 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
  • 2
12 Comments
 
LVL 47

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 47

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
 

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 47

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

729 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