?
Solved

HOW TO PRINT TO A UNIX NETWORK PRINTER

Posted on 2006-07-19
4
Medium Priority
?
231 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
[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
  • 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 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 8 hours left to enroll

765 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