Solved

HOW TO PRINT TO A UNIX NETWORK PRINTER

Posted on 2006-07-19
4
220 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

763 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

9 Experts available now in Live!

Get 1:1 Help Now