View Single Post
 
Old 02-17-2021, 04:35 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,105
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Bearing in mind that I don't have access to your printer to check it, the following should work. As I indicated in my web page some printers don't respond to calling the trays by name and require the tray IDs as described on the web page.

In which case Options.DefaultTray would have to be Options.DefaultTrayID and the two IDs would replace the values sLetterhead and sPlain.

I have turned off background printing as this is presumably a shared printer

Code:
Sub PrintToTrays()
Dim sCurrentPrinter As String
Dim sTray As Long
Const sLetterhead As String = "Drawer 3"
Const sPlain As String = "Multi-purpose Tray"

    With Dialogs(wdDialogFilePrintSetup)
        Options.DefaultTray = sLetterhead
        PrintIt "1"

        Options.DefaultTray = sPlain
        PrintIt "2"

        Options.DefaultTray = sLetterhead
        PrintIt "3-5"

        Options.DefaultTray = sPlain
        PrintIt "6-7"

        Options.DefaultTray = sLetterhead
        PrintIt "8"

        Options.DefaultTray = sPlain
        PrintIt "9-999"

        .Execute
    End With
End Sub

Sub PrintIt(sPrintRange As String)
    Application.PrintOut FileName:="", _
        Range:=wdPrintRangeOfPages, _
        Item:=wdPrintDocumentWithMarkup, _
        copies:=1, _
        Pages:=sPrintRange, _
        PageType:=wdPrintAllPages, _
        collate:=True, _
        Background:=True, _
        PrintToFile:=False, _
        PrintZoomColumn:=0, _
        PrintZoomRow:=0, _
        PrintZoomPaperWidth:=0, _
        PrintZoomPaperHeight:=0
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote