Using the Papersource attribute to select a Paper Tray

I have an HP Laser with 2 Trays: a manual feed and a lower paper tray

I am using the following to get the paper source:

PrivateFunction GetPaperSource(ByVal psAs PrinterSettings,ByVal KindAs PaperSourceKind)As PaperSource

Dim pscAs PaperSource

ForEach pscIn ps.PaperSource

If psc.Kind = KindThen

Return psc

EndIf

Next

' No match? Simply return the 0th source.

Return ps.PaperSources(0)

EndFunction

In my Print Click event for the manual tray option button:

PrivateSub btnPrint_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles btnPrint.Click

PrintDocument1.DefaultPageSettings.PaperSource = GetPaperSource(PrintDocument1.PrinterSettings, PaperSourceKind.Manual)

PrintDialog1.Document = PrintDocument1

If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OKThen

PrintDocument1.Print()

EndIf

EndSub

In my Print Click event for the lower tray option button:

PrivateSub btnPrint_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles btnPrint.Click

PrintDocument1.DefaultPageSettings.PaperSource = GetPaperSource(PrintDocument1.PrinterSettings, PaperSourceKind.Lower)

PrintDialog1.Document = PrintDocument1

If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OKThen

PrintDocument1.Print()

EndIf

EndSub

No matter what I try this is not working. The Printer defaults to Automatic Feed andif there is paper in the manual tray then it always selects the manual tray. I am not able to successfully execute the option to select the lower tray. I have tried searching on Google and I cannot find an answer. The printer default is AUtomaticFeed and I am no able to override that programmatically.

[5402 byte] By [trekkie25] at [2007-12-24]