View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default I can't quite get the syntax for printing to the manual feed tray

Send keys goes to the activewindow.

You would have to use low level file io to write to the printer.

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 ine " + Str(ctrl)
Print #1, tmpstr
Next
tmpstr = "[End of printing test]" + Chr(12)
Print #1, tmpstr
Close #1
End Sub


To a Network printer


First, I went to the immediate window in the VBE to query the activeprinter
string


? activePrinter
\\ARDAPS01\1D343E on Ne02:

then I used the first part in the below code:

Sub Macro5()
Dim ctrl As Long
Dim tmpstr As String
Open "\\ARDAPS01\1D343E" 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

Worked for me.

You would need to send you sequence to the printer.

All that said, I am not sure that will work if you then try to print through
windows using Printout. I believe that will go through the print driver and
send new settings (those selected in the print driver/print setup) to the
printer. However, it shouldn't be hard to test.



Regards,
Tom Ogilvy


"Sharlene England" wrote in message
...
Below is my code, and the escape sequence is correct as it does work in an
old wordperfect macro, but in excel this printout never goes to the

correct
tray, any ideas?

Thanks.

ActiveSheet.PageSetup.PrintArea = "$A$1:$U$52"
With ActiveSheet.PageSetup
.LeftMargin = Application.InchesToPoints(0.45)
.RightMargin = Application.InchesToPoints(0.25)
.TopMargin = Application.InchesToPoints(0.73)
.BottomMargin = Application.InchesToPoints(0.4)
.HeaderMargin = Application.InchesToPoints(0.5)
.FooterMargin = Application.InchesToPoints(0.43)
.PrintQuality = 600
End With

' selects the manual page tray without printing
SendKeys "{ESC}&l8H"
ActiveWindow.SelectedSheets.PrintOut Copies:=2, Collate:=True