ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Printing Text from Excel (https://www.excelbanter.com/excel-programming/306239-re-printing-text-excel.html)

Tom Ogilvy

Printing Text from Excel
 
Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing Line " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


replace LPT1 with the device name.

--
Regards,
Tom Ogilvy

"RonF" wrote in message
...
I want to send a string of test to the printer while running in excel
automation. The only way I've found to to this is first put the text in

an
unused cell, select the cell and then print the cell using
selection.printout. Does anyone know of a more direct way?
--
Thanks
RonF




RonF[_2_]

Printing Text from Excel
 
Thanks, this should work.



"Tom Ogilvy" wrote:

Sub Macro5()
Dim ctrl as Long
Dim tmpstr as String
Open "LPT1:" For Output As #1
Print #1, "[Start of Printing Test]"
For ctrl = 1 To 10
tmpstr = "Printing Line " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


replace LPT1 with the device name.

--
Regards,
Tom Ogilvy

"RonF" wrote in message
...
I want to send a string of test to the printer while running in excel
automation. The only way I've found to to this is first put the text in

an
unused cell, select the cell and then print the cell using
selection.printout. Does anyone know of a more direct way?
--
Thanks
RonF






All times are GMT +1. The time now is 02:56 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com