Solved

HOW TO PRINT TO A UNIX NETWORK PRINTER

Posted on 2006-07-19
4
225 Views
Last Modified: 2010-04-30
I would like to print labels to a zebra printer.  I am able to print to the zebra printer using the attached code in my visual basic 6 application as long as the printer is defined to my personal computer.  However, I would like to print to zebra printers that reside on our unix network.  Can you give me an example as to how I can point to a network printer in my vb code by using the ip address, etc.  I need to substitute the line below where the devicename is used with some code to connect to our unix network server.

 'If UCase(printerObj.DeviceName) = UCase("Zebra16") Then
        If UCase(printerObj.DeviceName) = UCase(sparm5) Then

================================================

Private Sub Command1_Click()
  Dim printerObj As Printer
  Dim v_appt_nbr As Double
  Dim v_po    As String
  Dim v_seq_nbr    As String
  Dim v_short_prefix As String
  Dim v_prefix As String
  Dim v_container_id As String
  Dim v_printer_name As String
  Dim v_label_cnt As String
  Dim strsql As String
  Dim sarg As String
  Dim iq As Integer
  Dim lrec As Long
  Dim iSpace As Integer
  Dim srec As String
  Dim sRem As String
  Dim connect As String
  Dim v_label_text As String
  Dim v_count As Long
 
  Set objconn = New ADODB.Connection
  Set rszebra = New ADODB.Recordset
   
  con.Open "provider=msdaora;data source='" & strdb & "';user id='" & struser & "';password='" & strpwd & "';"
   
  'GET INTERNAL ROUTING INFO
  strsql = "select  prefix,appt_nbr,po_nbr,seq_nbr"
  strsql = strsql & " from test_table"
  strsql = strsql & " where rownum < 2"
  strsql = strsql & " order by seq_nbr"
  rszebra.Open strsql, objconn

  v_printer_name = sparm5
 
  Do While Not rszebra.EOF
 
     v_count = v_count + 1
   
     v_prefix = Trim(rszebra.Fields(0))
     v_appt_nbr = Trim(rszebra.Fields(1))
     v_po = Trim(rszebra.Fields(2))
     v_seq_nbr = Trim(rszebra.Fields(3))

     v_container_id = v_prefix & "" & v_appt_nbr & "" & v_po & "" & Spad(v_seq_nbr, 4)
     rszebra.MoveNext
   
     
   
   For Each printerObj In Printers
        v_label_text = (v_count & " Of " & sparm6)
       
     '  If UCase(printerObj.DeviceName) = "IT8DN on GFCMS013" Then
       'If UCase(printerObj.DeviceName) = UCase("Zebra16") Then
        If UCase(printerObj.DeviceName) = UCase(sparm5) Then
           Set Printer = printerObj
        Exit For
        End If
   Next
           
       'ALL LABELS
        Printer.Print "^XA^MCY^JMA^XZ^XA^PRA^XZ^XA^LH0,0^XZ^XA"
        Printer.Print "^FO101,30^CFB,16^FDAPPT NBR " & v_appt_nbr & "^FS"
        Printer.Print "^FO101,60^BY4^BCN,197,N^FD>;" & v_container_id & "^FS"
        Printer.Print "^FO101,273^CFB,16^FD" & v_container_id & "^FS"
        Printer.Print "^FO99,295^CFB,16^FD " & v_label_text & "^FS"
        Printer.Print "^PQ1^MCY^XZ"
        Printer.EndDoc
       
     Loop
      rszebra.Close

End Sub

================================================

  Thanks
0
Comment
Question by:ratliffjm
  • 2
  • 2
4 Comments
 
LVL 4

Expert Comment

by:JRCSystems
ID: 17163199
I don't think you have an entirely VB-type problem.

For starters, can you make this happen:
Delete/Un-install the printer from your computer.
Install the printer across the network on your print-server.
Share the printer in Windows.

Go to a computer that did not have the Zebra printer installed.
Tell Windows to Add a New Network printer.
Browse across the network, and point to the Zebra.
When its done, print a test page.

IF you can make THAT work, then VB is a no-brainer at that point.

Before you involve VB, slightly complicating the issue, find out if the printer works in plain-old-Windows.
If that is a "YES", then...

Somewhere on the remote/client computer, in VB's printer collection,
you would find a printer devicename \\[printer server]\[zebra model # share name]

Dim poPrinter as Printer
Dim pbFound as Boolean

       for each poPrinter in Printers
              if instr(1, ucase$(poPrinter.devicename), "\\ your printer server \ share name " ) > 0 then
                        Set Printer = poPrinter
                        pbFound  = True
              end if
      next poPrinter

       if not pbFound then MsgBox "Contact Network Administrator": Exit Sub

...
      continue your print program....





0
 

Author Comment

by:ratliffjm
ID: 17364049
Thanks for your response. I am now able to print to the zebra printer (ex. Zebra15)  using the attached code in my visual basic 6 application on some computers and not others even though the printer has been installed and shared on the network.

It's really weird, do you have any idea why it would print from some computers and not others?  Could it be a windows authentication issue, etc.  The Desktop computers they are using are Dell computers with Windows 2000 software.  The users must supply a login password before they can print.  The application accesses oracle tables and retrieves data from an oracle database and uses it to print labels.  Any ideas?

       Thanks
0
 
LVL 4

Accepted Solution

by:
JRCSystems earned 500 total points
ID: 17368113
Going back to my previous post...

On the computers that don't print from your program,
CAN THEY PRINT a TEST PAGE from WINDOWS?
Use that as a starting point, taking VB out of the picture.

Yes, my best guess at this point would be toward a security-related issue.

0
 

Author Comment

by:ratliffjm
ID: 17381278
Thanks!
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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