Solved

Set paperbin

Posted on 1998-07-07
5
211 Views
Last Modified: 2009-12-16
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
Comment
Question by:ga
  • 3
  • 2
5 Comments
 
LVL 2

Accepted Solution

by:
swilt earned 100 total points
ID: 1465137
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
 

Author Comment

by:ga
ID: 1465138
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
 
LVL 2

Expert Comment

by:swilt
ID: 1465139
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
 

Author Comment

by:ga
ID: 1465140
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
 
LVL 2

Expert Comment

by:swilt
ID: 1465141
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now