Solved

Set paperbin

Posted on 1998-07-07
5
219 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

728 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