Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending data to a USB printer (Excel) 1

Status
Not open for further replies.

GVF

Programmer
Feb 25, 2005
160
US
In Excel...
I collect data through a serial port and paste it to a worksheet. I also send the data to a printer so there is a hard copy (department of redundancy department). This works if the printer is connected to a parallel port. Does anyone know how to send a string to a USB printer?
Parallel port code looks like this:

Open "LPT1:" for output as #1
Print #1, DataStr

The printer sits quietly until a sheet has been filled up and then spits out the sheet. When data collection is complete:

Print #1, chr(10)
Close #1

The last (incomplete) sheet is flushed from the printer.
Parallel port printers are going the way of serial ports. I cannot get "Ne01" or "DOT4_001" or "USB001" or any variation of a USB port name to work. Any help would be appreciated.
 
How are you sending the data in excel to the printer? I may be missing the point here but why not just use the Worksheet PRINTOUT method in vba. This has an optional parameter where you can specify the name of the printer you want to print on

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
Hello,
The worksheet isn't filled line by line. Race data comes in from a timer. Start times are subtracted from finish times, the worksheet is searched for a name and the net time is pasted in for that racer. Might be row 2, might be row 200. So the data is scattered all over as it comes in. I was mandated to send the raw data strings to a printer as they were received (every start and every finish). This worked well for parallel port printers. The operators were happy that they had a raw data sheet to refer to in case of inquiries regarding the data. I haven't been able to duplicate this with USB printers. I have changed the code to write lines to a text file as an alternative but now the operators aren't happy because they have to open another file to view the data. I was hoping someone had a way to send strings to the USB printers.
I sent the code to parallel port printers with the code listed in my opening question. It isn't the data from Excel I am sending but rather the raw time-of-day data as received from the timer.

Code:
     Open "LPT1:" for Output as #1
'elswhere in a loop...
     Print #1, DataStringFromTimer
'I guess the data sits in the printer memory until the printer notices that it has received 80 lines, it will activate and print the sheet.  On the dialog box is a button that sends a chr(10) to the printer telling it to print a sheet whether it is full or not allowing the operator to immediately refer to the raw data...
     Print #1, chr(10)
When the dialog box is dismissed...
     Close #1
At any rate, this has had me stumped for a long time and my internet searches tell me that I'm not the only one having trouble with virtual printer ports.
 
Sorry - don't know command prompt stuff like that....

Rgds, Geoff

We could learn a lot from crayons. Some are sharp, some are pretty and some are dull. Some have weird names and all are different colours but they all live in the same box.

Please read FAQ222-2244 before you ask a question
 
ok, by [tt]isn't formfeed chr(12)?[/tt] i meant that [tt]Print #1, chr$(10)[/tt] will only increment the line counter by 1. if you want to throw a page you have to send [tt]chr$(12)[/tt].


mr s. <;)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top