Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

HOW TO PRINT TO A UNIX NETWORK PRINTER

Posted on 2006-07-19
4
Medium Priority
?
232 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
Suggested Courses

618 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