paper size by name

S

Stefi

Hi All,

When I use custom paper size, first I define it for the printer by
submitting its name and page lenght and width. Windows assigns to it a code
number, and when I record a macro printing on this paper size, the macro
contains this code number, like
..PaperSize = 125
It's hard to remember to code numbers. Is there any way in VBA to refer to a
custom paper size by its name?

Thanks,
Stefi
 
M

meh2030

Hi All,

When I use custom paper size, first I define it for the printer by
submitting its name and page lenght and width. Windows assigns to it a code
number, and when I record a macro printing on this paper size, the macro
contains this code number, like
.PaperSize = 125
It's hard to remember to code numbers. Is there any way in VBA to refer to a
custom paper size by its name?

Thanks,
Stefi

Stefi,

Search the VBE Help for PaperSize, click the PaperSize Property, and
then when the help box opens, click the blue link labeled
"XlPaperSize".

Matt
 
S

Stefi

Hi Matt,

Thanks for your reply, I followed the link you suggested, and found names
for pre-defined paper sizes, and one for user defined size: xlPaperUser, but
there is no help on how to assign a value to this name, and how can I handle
more than one custom paper sizes.
Can you give me some more assistance?

Regards,
Stefi


„[email protected]†ezt írta:
 
S

Stefi

Via Windows Control Panel/Printers and Faxes/Printer Properties/General
tag/Printing settings/Paper-Quality tag/Custom Paper Size

Sorry if some words don't match the originals, I'm tanslating them back from
Hungarian.

Stefi


„NickHK†ezt írta:
 
N

NickHK

It would seem that Custom paper info (Forms in Windows) is stored in the
Registry at:
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Print\Forms

I'm not sure how these relate to the numbers you set for .PaperSize though.
e.g. For my Acrobat PDF printer, setting papersize to ARCH A ( a custom size
presumably installed by this printer), gives a value of .PaperSize=125.

As there seems no direct link in this area of the registry that I can see,
you may have to resort to the API, specifically using the DEVMODE structure
and get its dmFormName element.
This shows you all you need for dealing with Printers:
http://vb.mvps.org/samples/project.asp?id=PrnInfo

NickHK
 
N

NickHK

That should be :
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Forms

NickHK
 
Joined
Oct 14, 2011
Messages
1
Reaction score
0
Using PaperSize in Excel VBA

Hello everyone!

I discovered how to configure PaperSize in Excel VBA (User Sizes)

On Windows, set the printer to the sizes you will use within Excel:

Open Printers and Faxes
Select the printer
Among Properties
Click: Printing Preferences
Paper / Quality
Changing the paper size from A4 to custom
Paper Options \ Custom \ Name
Give a specific name:

'Label_P' (small label) or 'Label_G' (major label)

Change width and height desired: Paper Options \ Custom \ Size

Width = 99.0 cm
Height = 307 cm

(Settings for 'Label_G' - major label)

Save the new size chosen - Close

In the previous window, give the same name in the Quick Sets

'Label_P' (The name for small label I'm using)
or
'Label_G' (major label name)

Save and press OK, OK and exit the configuration of this printer.

Now open the registry editor,

Go to:

HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Control \ Print \ Printers \ "Your Printer's Name" \ PaperName

ex:

HKEY_LOCAL_MACHINE \ SYSTEM \ ControlSet001 \ Control \ Print \ Printers \ HP LaserJet M1132 MFP Professional \ PaperName

In the right window, you will see the name given to your configuration:

'Label_P'

and

'Label_G'

and the corresponding numbers that Windows has created, in my case:

512 for 'Label_P'

513 for 'Label_G'

write down these numbers, exit the editor and use them in your Excel VBA programming in the configuration:

With Worksheets(1).PageSetup
....
PaperSize = 512 (or PaperSize = 513)
.....
End With

good luck

Luiz Augusto de Oliveira
14/10/2011
 
Top