• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 222
  • Last Modified:

Set paperbin

I can get the number and names of the available paperbin
with the DeviceCapabilities-api, but how can I set a
paperbin (using api-calls)
0
ga
Asked:
ga
  • 3
  • 2
1 Solution
 
swiltCommented:
Bins and Trays (Tested using a HP5si)

Declare Function Escape Lib "gdi32" (ByVal hdc As Long, ByVal nEscape As Long, ByVal nCount As Long, ByVal lpInData As String, lpOutData As Any) As Long

Private Function PaperSource(ByVal nTray As Integer) As Integer
    'Values for nTray
    ' 0 Print/eject page
    ' 1 Tray 2
    ' 2 Manual feed paper
    ' 3 Manual feed envelope
    ' 4 Tray 3
    ' 5 Tray 4 (2000 sheet)
    ' 6 envelope feeder
    ' 7 Auto select tray
    ' 8 Tray 1
    PaperSource = EscapePrinter(nTray, "H")
End Function

Private Function PaperDest(ByVal nTray As Integer) As Boolean
    'Values for nBin
    ' 0 Auto select bin
    ' 1 Top bin (Face down)
    ' 2 Top bin (Face up)
    ' 3 Side bin
    ' 4 Mailbox bin 1
    ' 5 Mailbox bin 2
    ' 6 Mailbox bin 3
    ' 7 Mailbox bin 4
    ' 8 Mailbox bin 5
    ' 9 Stitcher bin
    PaperDest = EscapePrinter(nTray, "G")
End Function

Private Function EscapePrinter(ByVal nNum As Integer, ByVal sChar As String) As Boolean
    Const PASSTHROUGH = 19
   
    Dim sPcl As String, ret As Integer
   
    sPcl = Chr$(27) & "&l" & Trim$(nNum) & sChar
    sPcl = Chr$(Len(sPcl) Mod 256) & Chr$(Len(sPcl) \ 256) & sPcl
    Printer.Print
    ret = Escape(Printer.hdc, PASSTHROUGH, 0, sPcl, 0&)
    Printer.CurrentY = 0
    EscapePrinter = (ret > 0)
End Function


0
 
gaAuthor Commented:
This code doesn't work on my printer (HP 4si mx)
the returnvalue of the escape-api = -1
am i doing something wrong (is this code suiteble for any printer)
is there an other way to solve this problem ?

0
 
swiltCommented:
http://www.micronet.fr/~okaczmar/q96795.htm
This is the place where I got the info from to write the code. You will notice I have modified the code a bit (from 16 to 32 bit). With your printer manual, this code and my code you should be able to work it out, if not leave a note and I will have another look.

The problem will be in the sPCL string (look at printer escape code in your manual)

And of course;
If the printer driver does not support the PASSTHROUGH printer escape, you must use the DeviceCapabilities() and ExtDevMode() functions instead.
0
 
gaAuthor Commented:
What I want is that the code is suiteble for any printer
When I use the DeviceCapabilities-api, I can get a list with
the available paperbins, but I don't know how to select one

0
 
swiltCommented:
This gave me a value of 5 for Escape

PaperDest 1
Printer.Print "Hello"
Printer.EndDoc

Why don't you want to use Printer.PaperBin ?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now