custom paper size

  • Thread starter Thread starter Mike Kim
  • Start date Start date
M

Mike Kim

Hi there,

I would like to know how to set up PaperSize. Let's say I have a custom
paper designed for barcode label printing and the dimension is 1.25" X 1". I
can set this up manually from Excel by going to File/ Page Setup and
selecing from the dropdown list, which has 1.25" X 1".

I have a VB.net application that creates excel worksheet on the fly.
so far this is what i have

objSheet.PageSetup.PaperSize = Excel.XlPaperSize.------(something)
but there is no 1.25" x 1" paper size in the value list.

any help will be appreciated. thanks
 
I believe you would have to use xlPaperUser

then you would have to set the custom size using the windows API (same as
setting it in the print driver manually)
 
thanks tom.

i tried to use xlPaperUser but gave up after fiddling it for a while. I
could not find any documentation pertaining to this issue. if you know how
to use windows api to accomplish this, can you post some sample codes. i
would appreciate it.
 
Mike,

Manipulating the printer settings from the registry is
rather complicated.

It depends on operating system etc etc. A while back i've written an
experimental addin MultiTrayPrint to switch printertrays.

Although unused in the interface a lot of background stuff
(like papersizes, bin to size mapping, etc etc) has been
programmed into classmodules in the addin, and you may be able
to use / adapt it to suit your needs.

The code is NOT documented.. but fairly structered.
It involves some 15 API functions and may be instructive.

Download it from my site and have a look.
http://members.chello.nl/keepitcool/download.html


Any comments appreciated!



keepITcool

< email : keepitcool chello nl (with @ and .) >
< homepage: http://members.chello.nl/keepitcool >
 
Hello Mike Kim

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' - My 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 ActiveSheet.Selection.PageSetup
....
PaperSize = 512 (or PaperSize = 513 or ....)
.....
End With

good luck

Luiz Augusto de Oliveira
14/10/2011
 
Back
Top