We help IT Professionals succeed at work.

In VBA, how do I use the "Open" command to print to a TCP/IP printer?

I have a Zebra S4M network printer (Ethernet connection) on a Windows Server 2003 network where the users are running an Access 2007 application.
Because of problems with Access Reports and barcode fonts, I am having to send Zebra Programming Language (ZPL) commands directly to the printer to print some barcode labels.
In VBA I am using an "Open strPrinterName For Output As #intFreeFile" instruction to open the link to the printer, but am having a problem with the "strPrinterName" when the printer is a "TCP/IP" device with its own IP address.
I have tried the full printer name, the port name and the IP address but none of these have worked.
I have managed to get it to work by making the printer "shared" on a particular PC and used the syntax "\\PCName\ShareName", but presumably that PC needs to be switched on for this to work and this seems to defeat the purpose of having a truly networked printer.

The Zebra S4M printer has what they call a "Zebra Printserver" installed but I have not been able to see the name of that printserver anywhere?

Can anyone help with the naming of this printer for my VBA code so that I am not dependent on a "share" on a particular PC?

Many thanks.
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Have you contacted the folks that make the printer? Often they'll have complete examples of usage. If they have examples in VB, you can normally use those directly in VBA.

1. You can share your printer on server
2. Try to use IP address as the printer name (\\xxx.xxx.xxx.xxx). (If you can connect printer to any computer, look to connected port properties, may be there are some name after IP address)


Thanks for the replies,

LSMConsulting : A week or so ago Zebra were not particularly helpful when I first approached them about printing barcodes to the printer from GUI Access Reports. I had naively thought that having a text control with a barcode font would have been sufficient, but it wasn't and I have had to revert to using explicity ZPL commands. Zebra pretty much just told me I had to buy in barcode fonts from third parties and they (Zebra) couldn't guarantee that they would work.
The re-seller I bought the printer from has been more helpful and came up with the "shared printer" strategy.

als315 : When I try the "\\xxx.xxx.xxx.xxx" type of name I get an Access run-time error number 52 - "Bad file name or number".


By making the printer "shared", I was able to use the "\\HostName\PrinterName" syntax with the VBA "Open" command. By doing this on the server rather than a workstation PC, I am hopefully able to avoid the possible problem of the "Host" not being switched on when a user runs the VBA procedure.
Many thanks.