Solved

How to set default paper size

Posted on 1998-11-08
6
519 Views
Last Modified: 2010-04-30
How to set the default paper size in VB6 and Win NT 4.0 SP3.
The default paper size in the default printer is Letter and I want to change it in A4.
0
Comment
Question by:zutphen
  • 3
  • 2
6 Comments
 
LVL 2

Expert Comment

by:schild
ID: 1443857
You set it ussing the folowing command:

Printer.PaperSize = <Paper Size Constant>


Constant              Value      Description
_____________________________________________
vbPRPSLetter              1      Letter, 8 1/2 x 11 in.
vbPRPSLetterSmall      2      Letter Small, 8 1/2 x 11 in.
vbPRPSTabloid              3      Tabloid, 11 x 17 in.
vbPRPSLedger              4      Ledger, 17 x 11 in.
vbPRPSLegal              5      Legal, 8 1/2 x 14 in.
vbPRPSStatement              6      Statement, 5 1/2 x 8 1/2 in.
vbPRPSExecutive              7      Executive, 7 1/2 x 10 1/2 in.
vbPRPSA3      8      A3, 297 x 420 mm
vbPRPSA4      9      A4, 210 x 297 mm
vbPRPSA4Small      10      A4 Small, 210 x 297 mm
vbPRPSA5      11      A5, 148 x 210 mm
vbPRPSB4      12      B4, 250 x 354 mm
vbPRPSB5      13      B5, 182 x 257 mm
vbPRPSFolio      14      Folio, 8 1/2 x 13 in.
vbPRPSQuarto      15      Quarto, 215 x 275 mm
vbPRPS10x14      16      10 x 14 in.
vbPRPS11x17      17      11 x 17 in.
vbPRPSNote      18      Note, 8 1/2 x 11 in.
vbPRPSEnv9      19      Envelope #9, 3 7/8 x 8 7/8 in.
vbPRPSEnv10      20      Envelope #10, 4 1/8 x 9 1/2 in.
vbPRPSEnv11      21      Envelope #11, 4 1/2 x 10 3/8 in.
vbPRPSEnv12      22      Envelope #12, 4 1/2 x 11 in.
vbPRPSEnv14      23      Envelope #14, 5 x 11 1/2 in.
vbPRPSCSheet      24      C size sheet
vbPRPSDSheet      25      D size sheet
vbPRPSESheet      26      E size sheet
vbPRPSEnvDL      27      Envelope DL, 110 x 220 mm
vbPRPSEnvC3      29      Envelope C3, 324 x 458 mm
vbPRPSEnvC4      30      Envelope C4, 229 x 324 mm
vbPRPSEnvC5      28      Envelope C5, 162 x 229 mm
vbPRPSEnvC6      31      Envelope C6, 114 x 162 mm
vbPRPSEnvC65      32      Envelope C65, 114 x 229 mm
vbPRPSEnvB4      33      Envelope B4, 250 x 353 mm
vbPRPSEnvB5      34      Envelope B5, 176 x 250 mm
vbPRPSEnvB6      35      Envelope B6, 176 x 125 mm
vbPRPSEnvItaly      36      Envelope, 110 x 230 mm
vbPRPSEnvMonarch      37      Envelope Monarch, 3 7/8 x 7 1/2 in.
vbPRPSEnvPersonal      38      Envelope, 3 5/8 x 6 1/2 in.
vbPRPSFanfoldUS              39      U.S. Standard Fanfold, 14 7/8 x 11 in.
vbPRPSFanfoldStdGerman      40      German Standard Fanfold, 8 1/2 x 12 in.
vbPRPSFanfoldLglGerman      41      German Legal Fanfold, 8 1/2 x 13 in.
 
vbPRPSUser      256      User-defined

0
 

Author Comment

by:zutphen
ID: 1443858
I want to change the properties of the printer. My problem is, that if user are logged in to our network the default paper-size is letter. If they want to print , they must first change the paper-size to A4. I want to make a little program that automatic change the paper-size of the default printer to a4.Proberly I must change the registry, but I can't find they right key(s) and value(s).

0
 
LVL 2

Expert Comment

by:schild
ID: 1443859
You set it ussing the folowing command:

Printer.PaperSize = <Paper Size Constant>


Constant              Value      Description
_____________________________________________
vbPRPSLetter              1      Letter, 8 1/2 x 11 in.
vbPRPSLetterSmall      2      Letter Small, 8 1/2 x 11 in.
vbPRPSTabloid              3      Tabloid, 11 x 17 in.
vbPRPSLedger              4      Ledger, 17 x 11 in.
vbPRPSLegal              5      Legal, 8 1/2 x 14 in.
vbPRPSStatement              6      Statement, 5 1/2 x 8 1/2 in.
vbPRPSExecutive              7      Executive, 7 1/2 x 10 1/2 in.
vbPRPSA3      8      A3, 297 x 420 mm
vbPRPSA4      9      A4, 210 x 297 mm
vbPRPSA4Small      10      A4 Small, 210 x 297 mm
vbPRPSA5      11      A5, 148 x 210 mm
vbPRPSB4      12      B4, 250 x 354 mm
vbPRPSB5      13      B5, 182 x 257 mm
vbPRPSFolio      14      Folio, 8 1/2 x 13 in.
vbPRPSQuarto      15      Quarto, 215 x 275 mm
vbPRPS10x14      16      10 x 14 in.
vbPRPS11x17      17      11 x 17 in.
vbPRPSNote      18      Note, 8 1/2 x 11 in.
vbPRPSEnv9      19      Envelope #9, 3 7/8 x 8 7/8 in.
vbPRPSEnv10      20      Envelope #10, 4 1/8 x 9 1/2 in.
vbPRPSEnv11      21      Envelope #11, 4 1/2 x 10 3/8 in.
vbPRPSEnv12      22      Envelope #12, 4 1/2 x 11 in.
vbPRPSEnv14      23      Envelope #14, 5 x 11 1/2 in.
vbPRPSCSheet      24      C size sheet
vbPRPSDSheet      25      D size sheet
vbPRPSESheet      26      E size sheet
vbPRPSEnvDL      27      Envelope DL, 110 x 220 mm
vbPRPSEnvC3      29      Envelope C3, 324 x 458 mm
vbPRPSEnvC4      30      Envelope C4, 229 x 324 mm
vbPRPSEnvC5      28      Envelope C5, 162 x 229 mm
vbPRPSEnvC6      31      Envelope C6, 114 x 162 mm
vbPRPSEnvC65      32      Envelope C65, 114 x 229 mm
vbPRPSEnvB4      33      Envelope B4, 250 x 353 mm
vbPRPSEnvB5      34      Envelope B5, 176 x 250 mm
vbPRPSEnvB6      35      Envelope B6, 176 x 125 mm
vbPRPSEnvItaly      36      Envelope, 110 x 230 mm
vbPRPSEnvMonarch      37      Envelope Monarch, 3 7/8 x 7 1/2 in.
vbPRPSEnvPersonal      38      Envelope, 3 5/8 x 6 1/2 in.
vbPRPSFanfoldUS              39      U.S. Standard Fanfold, 14 7/8 x 11 in.
vbPRPSFanfoldStdGerman      40      German Standard Fanfold, 8 1/2 x 12 in.
vbPRPSFanfoldLglGerman      41      German Legal Fanfold, 8 1/2 x 13 in.
 
vbPRPSUser      256      User-defined

0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:zutphen
ID: 1443860
Your answer is true with the current project, if the project has ended the default value is back to letter. It doesn't change the default printer, it must change a registry-key under HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Print\Printers. I want to change the default property under settings/printer/default printer.

0
 

Author Comment

by:zutphen
ID: 1443861
Adjusted points to 150
0
 
LVL 2

Accepted Solution

by:
Poddy earned 150 total points
ID: 1443862
You need to use the API

  Dim lngRet As Long
  Dim lngHPrinter As Long
  Dim lngDPMode As Long
  Dim dvmPaper As DEVMODE
  Dim dvmRet As DEVMODE
  On Error GoTo Err_SetPaper
    lngRet = OpenPrinter(pstrPrinterName, lngHPrinter, 0&)
      If lngRet = 0 Then
      Else
        lngDPMode = DM_MODIFY + DM_UPDATE
        dvmPaper.dmFields = DM_PAPERSIZE
        dvmPaper.dmPaperSize = pintPaperSize
        dvmPaper.dmSize = Len(dvmPaper)
        dvmRet.dmSize = Len(dvmRet)
        lngRet = DocumentProperties(0&, lngHPrinter, vbNullChar, dvmRet, dvmPaper, lngDPMode)
        ClosePrinter lngHPrinter
      End If
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Saving history changes to sub form 4 48
SLMGR Switches Are Not Working On KMS Host 3 113
how to Classify of email (pdf attachments) 7 45
Problem to line 23 54
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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…

828 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