PDA

View Full Version : open cash drawer using USB printer



gabriel26-28
03-29-2012, 04:15 PM
Hello Excellers

I used to work with a WIN XP PC before, that had parallel port to connect with POS printer. Now I have a Win 7 new PC, does not have parallel port but USB, so I bought an adapter USB/parallel.
My old code to print directly or to open cash drawer for a Cashier Application I have, doesn't work anymore. It was:

Sub drawer_opener()

Open "LPT1" For Output As #1
Print #1, "This is just a Test"
Print #1, Chr(27) + Chr(112) + Chr(0) + Chr(25) + Chr(250)
Close #1

End Sub
After some web research I have managed to get the exact character sequence to send to the printer via the only driver available, which is Generic/Text Only; but this command can be added to the Options in the driver's Control Panel only associated to: "Before Print" or "After Print",
and of course its only necessary to code a small Sub that sends an empty cell worth of printing to open the drawer AFTER the print out is performed.
This approach works fine.
My problem is that I need to open the drawer independently of any printing job and by using my small Sub mentioned above, I have to keep closing the drawer when its opening is not necessary.
Is there a way in VBA to handle the USB001 port and make direct communicaton with the printer?, any code?

I'd appreciate your help.
Gabriel