Skip navigation

Tag Archives: printer

Here we will access a network printer and set it to a local port using visual basic codes.
This procedure is good for sending Escape Codes to a printer.
For this example you will use an escape codes for Epson printer.

'Dos command to set an network printer to LPT1
Call Shell("cmd /c net use lpt1 //SeverName/SharedName",vbHide)

'Set LPT1 as an output device to be able to print directly to LPT1
Open "LPT1:" For Output As #1

'Epson escape code for Master Select & Draft
Print #1, Chr(27) & Chr(33) & Chr(1)
Print #1, Chr(27) & Chr(120) & Chr(48)

Print #1, "Hello, greatxam"

'Epson escape code for Form Feed
Print #1, Chr(12)

'Close LPT1
Close #1

'Remove connection to printer
Call Shell("cmd /c net use lpt1 /delete",vbHide)

Note:
ServerName is the hostname or an ip address where the printer is installed.
SharedName is the Shared name of the printer you want to access in the network.
Advertisements