Link to home
Start Free TrialLog in
Avatar of Jeff Heilman
Jeff HeilmanFlag for United States of America

asked on

Using LPR to print to IP Barcode printers VBA MS Access

I had this question after viewing Printing to File then Sending File to an IP.  Towards the end of the thread a comment was made that you can use <LPR -S printer_ip_address -P queue_name file_to_print> to print to any selected IP printer.

I'm developing an application where any tablet pc has to be able to print to any barcode printer (Right now it looks like they'll be Intermec PC43d's.  It's a nice solid little machine).  I have a 'Printers' table that lists the Printer name, IP address, port, location, etc.  The user will simply select the printer nearest to him and click print.

Going into this a few weeks ago I thought it would be relatively straight forward but have hit a wall.  I still believe it can be done without having to use Bartender or similar software.  Could anyone help steer me in the right direction to pull off the LPR method?

I appreciate your help!
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

What are you hung up on?

Jim.
This comment here lays it out:

https://www.experts-exchange.com/questions/28898167/Printing-to-File-then-Sending-File-to-an-IP.html?anchorAnswerId=41374164#a41374164

Setup your printer, with the port as a file.   Generate the file, then copy to the printer with the LPR command.

If that command is not available, you need to install it in Windows.

Jim.
Avatar of Jeff Heilman

ASKER

I really have no idea where to begin using LPR to send the Access Report to the selected IP address.  I was hoping someone would have a sample of VBA that would go into the OnClick event of the Print button.
Here is the port config on the server.  I set it to LPR and named the queue INTERMEC.User generated image
<<I'm developing an application where any tablet pc has to be able to print to any barcode printer (Right now it looks like they'll be Intermec PC43d's.  It's a nice solid little machine).  I have a 'Printers' table that lists the Printer name, IP address, port, location, etc.  The user will simply select the printer nearest to him and click print.>>

  The piece your missing I think is that you need a printer installed.  Access talks to the printer driver, and the printer drivers spits out something the printer can understand.

  LPR in the other thread was being talked about as a way of sending a file of print driver output because the printer could not be reached directly (was on a different network).

  If you can reach the printer directly, then you can set this up as a normal print setup.

Jim.
Thanks Jim, if I'm understanding you correctly there might be a glimmer of hope.  Unless by directly you mean having to install the specific printer before it can be used.

I do have the printer drivers installed on the PC, but really need a way to avoid having to install 15 or more printers on almost 100 tablets company wide.  I think that would be an administrative nightmare down the road when printers start burning out and need replaced.  I do have code that will find the default printer, loop through and list all installed printers, and then set the selected printer as default.  The issue there is that I only want to show the printers that are in their department.

Do you think there's a way to change an installed printers name, ip, and port and then print the report (bar code)?
<< Unless by directly you mean having to install the specific printer before it can be used.>>

 That's always true with Windows unless they are all the same printer type.   For example, all Zebra printers can understand a file encoded in ZPL (Zebra Programming Language).  While there are different commands, most zebra printers will work with a single file.

 That being the case, you could install one printer with it's port pointed to a file.  Once you have printed the Access label, you'd then have a file, which you could send to any of the printers using LPR (I'm mixing some things up there, but you get the jist of it as long as all the printers are similar, you could get away with it).

But if for example you had a printer that only understood PCL (Printer Control Language), and another that understood only PS (Post Script), then you can't take the printer driver for one and send the output from the driver to the other.

Make sense?

Jim.
OK, I think so.  I would print the label as a text file to C: and then send that label using LPR to any given printer's IP address and the printer would know what to do with it from there.

Thanks for hanging in there with me Jim.  One last request:  Do you have a sample of what the VBA would look like?
ASKER CERTIFIED SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
... print the label as a text file to C: and then send that label using LPR to any given printer's IP address and the printer would know what to do with it from there ...

As Jim Dettman has pointed out, the printer would only be able to do anything meaningful with the received data if that data consisted of 'printer instructions' in the format of (one of) the Page Description Languages (e.g. PCL5, PCL XL, PostScript, ZPL, PCLmS, EscP, etc.) supported by that target device.
Thanks Jim!