Finding printer trays and selecting which to print to from a word document using VB RRS feed

  • Question

  • HI Folks 

    I'm using VS2019 to program in visual basic, below is a very frustrating issue im trying to accomplish 


    • To create a word document using Dim oWord As Word.Application  - Complete 
    • Add bookmarks to the document - complete 
    • To then print the document to the default printer (whatever model) using a tray specified in the incoming csv data

    the last point is the issue, I cant print the document using  oWord.ActiveDocument.PrintOut() no problem but my issue is the changing of the tray numbers 


    1. oWord.ActiveDocument.PageSetup.FirstPageTray = Word.WdPaperTray.wdPrinterLowerBin  - doesnt print out from other tray also used otherpagestray
    2. oPS.DefaultPageSettings.PaperSource = oPS.DefaultPageSettings.PrinterSettings.PaperSources.Item("Tray 3") with oPS As New System.Drawing.Printing.PrinterSettings  -- is it find the paper sources in the oPS I can msgbox them and see "Tray 2" etc but cant seem to set the print to go to them 
    3. tried a print dialog, but the users doesn't want this extra layer as a lot of these are automated 

    ideally id just need to print to tray X, from the data sent no matter what printer it is. failing that I can catch any error and print from the printer default tray

    I'd hoped printing was well integrated into VS, being able to print to trays easily but I seem to be having a hard time doing it 

    Any ideas very welcome indeed 


    Tuesday, July 9, 2019 5:10 PM

All replies

  • Hi,

    Use the following code to  determine which tray to use:

     Dim pd1 As PrintDocument = New PrintDocument()
        For i As Integer = 0 To pd1.PrinterSettings.PaperSources.Count - 1

    Best Regards,


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Thursday, July 11, 2019 1:30 AM