Write characters to PRN or LPT1

tacieslik

Registered User.
Local time
Today, 16:21
Joined
May 2, 2001
Messages
244
Does anyone know what code will write the characters in a tables field to file using the PRN or LPT1 ports? First I'd like to get it printing to a file for debugging and then to the printer using the PRN or LPT1 port.

TIA
 
I am not sure about Access, but in VB you have to OPEN the LPT1 port to write directly to it. Then you could use the normal VB print commands (or Write depending on what you were doing) to send commands right to the printer. Don't know if that helps or not.
 
Thanks FoFa,

This sounds helpful. Would you know of any sample code for opening the LPT1 port and printing to it?
 
I don't have any, but if memory serves me (which it is not as I age) LPT1 was a reserved port command. You can only open it for output and you treated it like a file pretty much.
Open LPT1 as 1 for output (or something like that)
Then you used the file number to write to it.
 
Does anyone know what code will write the characters in a tables field to file using the PRN or LPT1 ports? First I'd like to get it printing to a file for debugging and then to the printer using the PRN or LPT1 port.

TIA

Filenumber = FreeFile ' Get unused file
Open "LPT1:" For Output As #Filenumber ' Create file name.

Print #Filenumber, " "
Print #Filenumber, "SAMPLE" ' Output text.
Close #Filenumber ' Close file.
 
You can open a device. Just remember that device format is devunit: if it is not a disk.

LPT1:, COM1:, COM3:, etc. - if they exist - can be directly opened through the VBA OPEN verb - with this little GOTCHA to be had... It is possible to just PRINT to the devices, but if you want anything else, you have to include explicit control characters such as vbCR, vbLF, vbCRLF, vbTAB, etc. etc. etc. - and note that if the device does not support hard tabs, forget about using vbTAB anyway.
 

Users who are viewing this thread

Back
Top Bottom