Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Printing to different tray

70 views
Skip to first unread message

Peter Kronenberg

unread,
May 19, 2004, 7:54:40 PM5/19/04
to
I'm trying to write a macro that prints to the lower tray of my
printer. Actually I want to print 2 copies of page 1 to the upper
tray and 1 copy of page 2 to the lower tray.
Everything works, except it's all printing to the upper tray. What am
I doing wrong?

Also, I tried to specify Pages:="1" and Pages:="2", but that didn't
work. It printed the whole file, so I had to go with specifying
Range, From and To. Am I missing something?

thanks

-------------------------

Sub MyPrint()

'
' MyPrint Macro
'
Application.ActivePrinter = "hp deskjet 5800 series"

Options.DefaultTrayID = wdPrinterUpperBin
ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo,
From:="1", To:="1", Copies:=2


Options.DefaultTrayID = wdPrinterLowerBin
ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo,
From:="2", To:="2", Copies:=1

End Sub

Peter Hewett

unread,
May 20, 2004, 12:06:33 AM5/20/04
to
Hi Peter Kronenberg

Try changing "Background:=True" to "Background:=False".

HTH + Cheers - Peter

Jonathan West

unread,
May 20, 2004, 4:18:38 AM5/20/04
to
Hi Peter,

Word's help and the VBA constants for paper trays are thoroughly misleading.
Take a look here for an article that helps straighten it all out.

Controlling the Printer from Word VBA
Part 1: Using VBA to Select the Paper Tray
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=101

--
Regards
Jonathan West - Word MVP
http://www.multilinker.com
Please reply to the newsgroup

"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message
news:nqsna09219cicsejg...@4ax.com...

Peter Kronenberg

unread,
May 20, 2004, 7:46:04 PM5/20/04
to
Thanks for the suggestion, but changing to Background:=False doesn't
seem to have any effect.

Peter Kronenberg

unread,
May 20, 2004, 7:47:44 PM5/20/04
to
Thanks, Jonathan. I had already found and read your article before I
posted. I tried the program and it confirmed that the codes my
printer used were the same as what Word was using. In other words,
UpperBin=1 and LowerBin=2. So no luck there.

Jonathan West

unread,
May 20, 2004, 7:57:49 PM5/20/04
to

"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message
news:6qgqa0h9rgso4ri99...@4ax.com...

> Thanks, Jonathan. I had already found and read your article before I
> posted. I tried the program and it confirmed that the codes my
> printer used were the same as what Word was using. In other words,
> UpperBin=1 and LowerBin=2. So no luck there.

OK, in that case, instead of setting the Options.DefaultTrayID, set the
trays for the document, like this

Sub MyPrint()

'
' MyPrint Macro
'
Application.ActivePrinter = "hp deskjet 5800 series"

ActiveDocument.PageSetup.FirstPageTray = wdPrinterUpperBin


ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo,
From:="1", To:="1", Copies:=2


ActiveDocument.PageSetup.PtherPagesTray = wdPrinterLowerBin


ActiveDocument.PrintOut Background:=True, Range:=wdPrintFromTo,
From:="2", To:="2", Copies:=1

End Sub


Peter Kronenberg

unread,
May 21, 2004, 8:21:29 AM5/21/04
to
Still no luck. I have tried every combination I can think of but just
can't get it to print from the bottom tray. I tried commenting out
the first PrintOut command, so that it just prints the 2nd page from
the bottom tray, but it prints to the upper tray.

Jonathan West

unread,
May 24, 2004, 10:56:39 AM5/24/04
to

"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message
news:nvsra0h2qv2kp5fus...@4ax.com...

> Still no luck. I have tried every combination I can think of but just
> can't get it to print from the bottom tray. I tried commenting out
> the first PrintOut command, so that it just prints the 2nd page from
> the bottom tray, but it prints to the upper tray.

Try setting the bottom tray using the Page Setup dialog. Then check the
value of the OtherPagesTray property from the immediate window. Then put
that value into your code.

Peter Kronenberg

unread,
May 25, 2004, 7:39:17 AM5/25/04
to
"Jonathan West" <jw...@mvps.org> wrote:

>
>"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message
>news:nvsra0h2qv2kp5fus...@4ax.com...
>> Still no luck. I have tried every combination I can think of but just
>> can't get it to print from the bottom tray. I tried commenting out
>> the first PrintOut command, so that it just prints the 2nd page from
>> the bottom tray, but it prints to the upper tray.
>
>Try setting the bottom tray using the Page Setup dialog. Then check the
>value of the OtherPagesTray property from the immediate window. Then put
>that value into your code.

Hi,
Not sure what you mean by checking the value from the immediate
window.

thanks,
Peter

Jonathan West

unread,
May 25, 2004, 8:07:31 AM5/25/04
to

"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message
news:b0c6b0duv5et1i4re...@4ax.com...

- Open the document.
- Using the Page Setup dialog, set the trays as you wish them to be
- Open the VBA editor.
- Press Ctrl-G to display the Immediate window
- In the immediate window, type the following (including the initial
question mark) and press enter

? ActiveDocument.PageSetup.FirstPageTray

This will give you th code value for that tray, which you should put into
your code.

Similarly, for the second tray, type the following

? ActiveDocument.PageSetup.OtherPagesTray

kpc

unread,
Jun 17, 2004, 4:36:31 AM6/17/04
to
Dear Peter

I have got round this by using first page tray and other pages tray
properties in document page setup. This might not be suitable for you as
you need to alter the page setup of the document or the template, but it
might point you in another direction.

Sub trayshow()
MsgBox "first page tray", vbOKCancel, ActiveDocument.PageSetup.FirstPageTray
MsgBox "rest of pages trays", vbOKCancel,
ActiveDocument.PageSetup.OtherPagesTray
End Sub

this gives code numbers for the pages that you can use within your code to
set the tray to print to

you can set these numbers with code

such as

ActiveDocument.PageSetup.FirstPageTray = 258
ActiveDocument.PageSetup.OtherPagesTray = 257

then just print it out

ActiveDocument.PrintOut


Hope this helps

Yours Kriss

"Peter Kronenberg" <pak@nospam_carouselpuppets.com> wrote in message

news:nqsna09219cicsejg...@4ax.com...

0 new messages