View Single Post
  #7   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Print Excel Directly to Printer

If you just want to send the command to the printer, that can probably be
done, but I doubt it would achieve what you want.

When you then print the worksheet through Excel and windows, it will send it
own settings that will probably override what you sent. However you might
as well give it a whirl and see.


This is how I print directly and it works for me:

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.

Regards,
Tom Ogilvy



"Windsong1948" wrote in message
...
Thank you anyway - At least you tried to help.

"Jim Cone" wrote:

"Do you know how a macro could be written
to include HP's ASCII printer codes for the drawer settings?"...
Sorry, can't help you there.

For what it's worth, I used multiple printer copies for a while with
different
settings. Didn't have a problem.
--
Jim Cone
San Francisco, USA
http://www.officeletter.com/blink/specialsort.html



"Windsong1948"

wrote in message
I have tried what you have suggested - the HP only uses one driver so
even
though I setup a new printer the same driver works for each so if I set
the
default drawer on the new printer I installed to drawer 3 it changes the
drawer to 3 on the original setup. Do you know how a macro could be
written
to include HP's ASCII printer codes for the drawer settings?


"Jim Cone" wrote:
Add three copies of your current printer, each with a different feeder
drawer set....HpLaserJet_dw2 and so on.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Windsong1948"

wrote in message
I am in a situation that I need to send an active sheet in Excel
directly to
the current printer bypassing the already set printer settings. My
printer
has 4 drawers w/different paper in each drawer. When I write a macro
it does
not change the drawer to the one I want to use and the settings I have
in my
books change from what I have them set at. I wish to make a macro for
each
drawer and use HP Printer control codes that will send my print to the
proper
drawer. Can this be done? I'm hoping you can help.