Solved

How do we inform the printer to print on selected paper size?

Posted on 2002-07-30
15
1,095 Views
Last Modified: 2012-06-27
Hi experts,
My printer supports several paper sizes and loaded with different paper sizes in the trays.

What should I do in my application, if I would like to print on a specific paper (It may not be default)?

With regards,
Narahari Sanga
0
Comment
Question by:nsanga
  • 6
  • 3
  • 3
  • +3
15 Comments
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7187489
You need to change the Printer.PaperSize Property:

see this link:
http://www.freevbcode.com/ShowCode.Asp?ID=3646#pagesize
0
 
LVL 7

Author Comment

by:nsanga
ID: 7187506
Hi ryancys,
Thank you for quick response and your suggestion.


I have checked the word document. It seems there are 2 options. One is to select Paper size and the other is to select the Paper Source. I would like to control the paper source as I am already setting the paper size.

With regards,
Narahari Sanga
0
 
LVL 7

Author Comment

by:nsanga
ID: 7187539
Hi ryancys,
Thank you for quick response and your suggestion.


I have checked the word document. It seems there are 2 options. One is to select Paper size and the other is to select the Paper Source. I would like to control the paper source as I am already setting the paper size.

With regards,
Narahari Sanga
0
 
LVL 2

Expert Comment

by:mmcmillen
ID: 7190506
you need to know the tray number. Beware, that tray number is NOT 1,2,3,4 etc.  You will need to access that by using some api's and then use printer.paperbin  command.

I can email you a vb program that displays all the tray info for all printers defined on your pc.  You can take the needed code from that and incorporate it into your application.  

What I did though was populate a table on the server with the printer name, and tray numbers.  So when my application needs to know, it queries that table and retrieves the tray numbers.
0
 
LVL 7

Author Comment

by:nsanga
ID: 7192583
Hi mmcmillen,
Thank you so much for your response and the suggestions. Please mail the program to nsanga@india.ingr.com

This will facilitate me to accept the answer if my problem is resolved. meanwhile, I will also check the MSDN for more clarity.

With regards,
Narahari Sanga
0
 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7192663
Hi nsanga,

mmcmillen may have the correct point.

Just wonder how to get PaperSource! I cant find a Property inside the Printer Object, so i do suspect that the PaperSource is Set from the Document we print, rather than from the Printer itself.

Here is some test from me:

'*You can get the Enum WdPaperTray from Word Object Library too

'    Private Enum WdPaperTray
'        wdPrinterAutomaticSheetFeed = 7
'        wdPrinterDefaultBin = 0
'        wdPrinterEnvelopeFeed = 5
'        wdPrinterFormSource = 15
'        wdPrinterLargeCapacityBin = 11
'        wdPrinterLargeFormatBin = 10
'        wdPrinterLowerBin = 2
'        wdPrinterManualEnvelopeFeed = 6
'        wdPrinterManualFeed = 4
'        wdPrinterMiddleBin = 3
'        wdPrinterOnlyBin = 1
'        wdPrinterPaperCassette = 14
'        wdPrinterSmallFormatBin = 9
'        wdPrinterTractorFeed = 8
'        wdPrinterUpperBin = 1
'    End Enum

Private Sub Command4_Click()        
    Dim iword As New Word.Application
    iword.Visible = True
    Dim idoc As Word.Document
    Set idoc = iword.Documents.add
    idoc.PageSetup.FirstPageTray = wdPrinterFormSource
    idoc.PageSetup.OtherPagesTray = wdPrinterPaperCassette
    idoc.Range.InsertAfter "Test"
    idoc.PageSetup.PaperSize = wdPaperA4
    Debug.Print Printer.PaperBin
End Sub

And the PaperBin return 15, which is equal to wdPrinterFormSource, note that this value cant be changed.

So, that's why i suspect the PaperSource Only can be set via the Document not from Printer.

* See if FirstPageTray and OtherPagesTray is what you looking for?

regards
0
 
LVL 7

Author Comment

by:nsanga
ID: 7192707
Hi experts,
I have done a small exercise before displaying the standard Page Settings dialog. I have set the following fields

DevMode.dmFields = DM_ORIENTATION Or DM_PAPERSIZE Or DM_DEFAULTSOURCE

Then it seems to be updating the source field with the one I selected in the dialog.
Am I going in the correct way?

mmcmillen,
Please comment. Also, u can provide the code in this place itself as ryancys did.

Thanks and regards,
Narahari Sanga
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 49

Expert Comment

by:Ryan Chong
ID: 7192744
Can i know what Object DevMode is, nsanga?
0
 
LVL 7

Author Comment

by:nsanga
ID: 7192791
Hi ryancys,
Please find the structure

   Type DEVMODE_TYPE
           ' Holds the Printer Name
           dmDeviceName As String * CCHDEVICENAME
           
           ' Holds the version
           dmSpecVersion As Integer
           
           ' Holds the version of the Printer Driver.
           dmDriverVersion As Integer
           
           ' Holds the total size of this structure
           dmSize As Integer
           
           ' Holds the total buffer required
           dmDriverExtra As Integer
           
        ' Holds the fields to be considered for the dialog
           dmFields As Long
           
           ' Holds the Paper orientation
           dmOrientation As Integer
           
           ' Holds the paper size
           dmPaperSize As Integer
           
           ' Holds the length of the paper.
           dmPaperLength As Integer
           
            ' Holds the width of the paper
           dmPaperWidth As Integer
           
           ' Hodls the Print scale
           dmScale As Integer
           
           ' Holds the no of copies to print
           dmCopies As Integer
           
           ' Holds the Paper source
           dmDefaultSource As Integer
           
           ' Holds the quality with  which to print
           dmPrintQuality As Integer
           
 ' Switches between color and monochrome on color printers.
           dmColor As Integer
           
          ' Holds the info as to simplex/duplex mode to use
           dmDuplex As Integer
           
           ' Holds the resolution to use
           dmYResolution As Integer
           
         ' Specifies how TrueType® fonts should be printed
           dmTTOption As Integer
           
 ' Specifies whether collation should be used when printing
           ' multiple copies
           dmCollate As Integer
           
     ' Specifies the name of the form to use; for example,
           ' "Letter" or "Legal".
           dmFormName As String * CCHFORMNAME
           
           ' Holds the buffer unused for padding
           dmUnusedPadding As Integer
           
' Specifies the color resolution, in bits per pixel, of the
           ' display device
           dmBitsPerPel As Integer
           
           ' Specifies the width, in pixels, of the visible device surface
           dmPelsWidth As Long
           
           ' Specifies the height, in pixels, of the visible device surface
           dmPelsHeight As Long
           
           ' Specifies the device's display mode
           dmDisplayFlags As Long
           
           ' Specifies the frequency, in hertz (cycles per second), of the
           ' display device in a particular mode.
           dmDisplayFrequency As Long
    End Type

With regards,
Narahari Sanga
0
 
LVL 2

Expert Comment

by:mmcmillen
ID: 7193389
I emailed the program. I believe I got it from Microsoft tech Support but not for sure.  
0
 
LVL 7

Author Comment

by:nsanga
ID: 7193419
Hi McMillen,
I received the files. Thank you so much.

I have gone through the code and it's perfectly getting all the trays available for all the printers installed on the system.

If we set the "dmDefaultSource" (see the structureabove) with the value obtained from the code, will it take the paper from that tray and print it? If the paper is not available in the selected tray (i.e, the one which we set), what will happen? Does it take from other trays?

Please tell me if you any idea about the above questions.

With regards,
Narahari Sanga
0
 
LVL 2

Accepted Solution

by:
mmcmillen earned 150 total points
ID: 7193442
That depends on your printer settings I think.  Let's say you have a 4 tray printer.  Trays 1 and 2 are configured as letter, tray 3 as a special form and 4 as 11X17.  If you tell the program to print to tray 2 and it runs out of paper, it should print automatically to tray 1.  Our printer has different formtypes configured for each tray since we must have certain docs printed on certain colored paper.  When we run out of paper in tray 2, even though tray 3 has 8.5X11, it is a different color so there is no switching .   Hope that helps.

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 8049127
Hi nsanga,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept mmcmillen's comment(s) as an answer.

nsanga, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 8095941
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0
 

Expert Comment

by:ahubacher
ID: 8388624
[quote]That depends on your printer settings I think.  Let's say you have a 4 tray printer.  Trays 1 and 2 are configured as letter, tray 3 as a special form and 4 as 11X17.  If you tell the program to print to tray 2 and it runs out of paper, it should print automatically to tray 1.  Our printer has different formtypes configured for each tray since we must have certain docs printed on certain colored paper.  When we run out of paper in tray 2, even though tray 3 has 8.5X11, it is a different color so there is no switching .[/quote]

So is it not possible to work with the paperbin property? Me to have problems with Printer.PaperBin. Setting the paperbin property to values which I am sure are right makes errors (invalid property value). The same problem with visual basic 4.0 and visual basic 6.0.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…

707 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

15 Experts available now in Live!

Get 1:1 Help Now