title: Choose Printer Tray automatically From Excel VBA to print Word Document
body: <p>I am trying to print Word Document From Excel
  I want to choose printer tray to print word document in default printer. 
  First 2 pages in Tray one (Letter Heads) and 3rd to 5th page in Tray Two (A4 Sheets) Using excel VBA.</p>
  
  <p>Below code is working fine to print in default printer and tray.
  Help me to Choose Trays</p>
  
  <pre><code>'Print in letter head:- Choose Tray one
  </code></pre>
  
  <p>and</p>
  
  <pre><code>'Print Other pages in A4:- Choose Tray Two
  </code></pre>
  
  <p>Printer details:</p>
  
  <p>*Network Printer
  *Hp Laser printer 5200 dtn</p>
  
  <pre><code>Dim directory As String, fileName As String, ans As String, i As Integer
              Dim objWord As Object
              Dim intpage As Integer, intcopies As Integer, intnrml As Integer
  
              Set objWord = CreateObject("Word.Application")
              objWord.Visible = True
  
              ' path to the folder
              directory = "C:\Users\bharath.a.raj.DIR\Desktop\Print\"
              fileName = Dir(directory &amp; "*.doc*") ' Open Multiple Word Docs Both .doc and .docx
              Do While fileName &lt;&gt; ""
              objWord.Documents.Open (directory &amp; fileName)
  
              On Error Resume Next
             '
              intcopies = CInt(InputBox("How many copies?"))
              intpage = 1 'Letter head page no.
              intnrml = 3 'A4 page no.
              On Error GoTo 0
  
              If intpage * intcopies &lt;&gt; 0 Then
                  For i = 1 To intcopies ' Loop to print next page of uer Choice Note: simplex is not working in my Office, Default Duplex
                      'Network Printer :- HP Laser Printer 5200dtn
                      'Print in letter head:- Choose Tray one
                      objWord.PrintOut Range:=4, Pages:=CStr(intpage) '1st page
                      intpage = intpage + 1
                      objWord.PrintOut Range:=4, Pages:=CStr(intpage) '2nd page
                      intpage = 1
                      'Print Other pages in A4:- Choose Tray Two
                      objWord.PrintOut Range:=4, Pages:=CStr(intnrml) '3rd page
                      intnrml = intnrml + 1
                      objWord.PrintOut Range:=4, Pages:=CStr(intnrml) '4th page
                      intnrml = intnrml + 1
                      objWord.PrintOut Range:=4, Pages:=CStr(intnrml) '5th page
                      intnrml = 3
  
                  Next
              Else
                  MsgBox "sorry, wrong page or copies, try again"
              End If
                 ' Next
              objWord.Documents.Close
                  ' set file to next in Dir
              fileName = Dir()
              Loop
  </code></pre>