Solved

how to get rid of the blank label after printing

Posted on 2014-11-29
12
268 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 45

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 45

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 

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 45

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:
SimonAdept 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:SimonAdept
SimonAdept 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

705 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

15 Experts available now in Live!

Get 1:1 Help Now