The PageSetup object represents the page layout properties of a printed
worksheet. To create a PageSetup object, use,
PageSetup Methods and Properties
|
| BlackAndWhite* |
Set the BlackAndWhite property to true
if you formatted data with colors, but are printing on a black
and white printer. If you are using a color printer, setting BlackAndWhite
to true may reduce printing time. BlackAndWhite is set to
False by default.
Example:
ws.PageSetup.BlackAndWhite = True
Top |
| BottomMargin* |
Set BottomMargin to specify distance
in inches between the worksheet data and the bottom edge of the
printed page. BottomMargin is set to 0 by default.
Example:
ws.PageSetup.BottomMargin = 1.25
Top |
| CenterFooter* |
Sets or returns a center footer that
will appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.CenterFooter = "centerfooter"
Top |
| CenterHeader* |
Sets or returns a center header that
will appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.CenterHeader = "centerheader"
Top |
| CenterHorizontally* |
When set to True, centers data
horizontally within the margins. CenterHorizontally is set to
False by default.
Example:
ws.PageSetup.CenterHorizontally = True
Top |
| CenterVertically* |
When set to True, centers data
vertically within the margins. CenterVertically is set to False
by default.
Example:
ws.PageSetup.CenterVertically = True
Top |
| Draft* |
Set Draft to true to reduce printing time.
When Draft is set to true, Excel does not print gridlines and
most graphics. Draft is set to False by default.
Example:
Top |
| FirstPageNumber* |
Sets or returns the first page
number for the printed worksheet. By default, the first page will
be 1, or, if the print job does not start with page 1, FirstPageNumber
will be the number of the first page in the sequence of pages
to print.
Example:
ws.PageSetup.FirstPageNumber = 2
Top |
| FitToPagesTall* |
Adjusts the height of the worksheet
or selection from worksheet to fit into a specified number of
pages. Use in conjunction with FitToPagesWide.
FitToPagesTall is set to 1 by default.
Note: The pair of properties FitToPagesWide and FitToPagesTall
and Zoom are mutually exclusive.
Example:
ws.PageSetup.FitToPagesTall = 2
ws.PageSetup.FitToPagesWide = 2
Top |
| FitToPagesWide* |
Adjusts the width of the worksheet
or selection from worksheet to fit into a specified number of
pages. Use in conjunction with FitToPagesTall.
FitToPagesWide is set to 1 by default.
Note: The pair of properties FitToPagesWide and FitToPagesTall
and Zoom are mutually exclusive.
Example:
ws.PageSetup.FitToPagesTall = 2
ws.PageSetup.FitToPagesWide = 2
Top |
| FooterMargin* |
User FooterMargin to adjust the distance
in inches between the footer and the top of the page. The FooterMargin
should be smaller than the BottomMargin
to prevent the footer from overlapping the data. FooterMargin is
set to .5 by default.
Example:
ws.PageSetup.FooterMargin= .5
Top |
| GetPrintTitles* |
Returns a Range
object that contains titles that will be repeated on each page
of a printed worksheet. The range returned by GetPrintTitles includes,
Top |
| HeaderMargin* |
Use HeaderMargin to adjust the distance
between the header and the top of the page. The HeaderMargin should
be smaller than the TopMargin to prevent
the header from overlapping the data. HeaderMargin is set to .5
by default.
Example:
ws.PageSetup.HeaderMargin= .5
Top |
| LeftFooter* |
Sets or returns a left footer that will
appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.LeftFooter = "leftfooter"
Top |
| LeftHeader* |
Sets or returns a left header that will
appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.LeftHeader = "leftheader"
Top |
| LeftMargin* |
Set LeftMargin to specify distance
between the worksheet data and the left edge of the printed page.
LeftMargin is set to 0 by default.
Example:
ws.PageSetup.LeftMargin = 1.25
Top |
| Order* |
Set the Order property to control the order
in which data is numbered and printed when it does not fit on
one page. The Order value names and codes are,
|
saxlDownThenOver
|
1
|
|
saxlOverThenDown
|
2
|
The figure below previews the direction that the document will
print when you set one of these values. Order is set to saxlDownThenOver
by default.

Example:
The following sets a worksheet's numbering and printing order
to over then down:.
ws.PageSetup.Order = saxlOverThenDown
Top |
| Orientation* |
Sets or returns the orientation of
the printed worksheet. Assign an Orientation value by its name
or code. The Orientation value names and codes are,
| saxlPortrait |
1 |
| saxlLandscape |
2 |
Orientation is set to saxlPortrait by default. The following
sets a worksheet's orientation to landscape.
set pagesetup = worksheet.pagesetup
pagesetup.orientation = 2
Top |
| PaperSize* |
Sets or returns the paper size for the
printed worksheet. Assign PaperSize by name or number, according
to the following table.
| saxlPaperLetter |
1 |
saxlPaperEnvelope12 |
22 |
| saxlPaperLetterSmall |
2 |
saxlPaperEnvelope14 |
23 |
| saxlPaperTabloid |
3 |
saxlPaperCsheet |
24 |
| saxlPaperLedger |
4 |
saxlPaperDsheet |
25 |
| saxlPaperLegal |
5 |
saxlPaperEsheet |
26 |
| saxlPaperStatement |
6 |
saxlPaperEnvelopeDL |
27 |
| saxlPaperExecutive |
7 |
saxlPaperEnvelopeC5 |
28 |
| saxlPaperA3 |
8 |
saxlPaperEnvelopeC3 |
29 |
| saxlPaperA4 |
9 |
saxlPaperEnvelopeC4 |
30 |
| saxlPaperA4Small |
10 |
saxlPaperEnvelopeC6 |
31 |
| saxlPaperA5 |
11 |
saxlPaperEnvelopeC65 |
32 |
| saxlPaperB4 |
12 |
saxlPaperEnvelopeB4 |
33 |
| saxlPaperB5 |
13 |
saxlPaperEnvelopeB5 |
34 |
| saxlPaperFolio |
14 |
saxlPaperEnvelopeB6 |
35 |
| saxlPaperQuarto |
15 |
saxlPaperEnvelopeItaly |
36 |
| saxlPaper10x14 |
16 |
saxlPaperEnvelopeMonarch |
37 |
| saxlPaper11x17 |
17 |
saxlPaperEnvelopePersonal |
38 |
| saxlPaperNote |
18 |
saxlPaperFanfoldUS |
39 |
| saxlPaperEnvelope9 |
19 |
saxlPaperFanfoldStdGerman |
40 |
| saxlPaperEnvelope10 |
20 |
saxlPaperFanfoldLegalGerman |
41 |
| saxlPaperEnvelope11 |
21 |
saxlPaperUser |
256 |
PaperSize is set to saxlPaperLetter by default.
Example:
ws.PageSetup.PaperSize = saxlPaperA4
Top |
| PrintArea* |
Sets or returns, as a Range
object, a worksheet's print area. The following example sets a
worksheet's print area to a range that begins at cell A1 and spans
20 rows and 10 columns.
pagesetup.printarea = ws.cells.range(1,1,20,10)
PrintArea can also be assigned using a string variable that has
been set to a specific Range because PrintArea is a Range.
Set pa = Ws.Cells.Range(1, 1, 20, 10)
Ws.PageSetup.PrintArea = pa
Top |
| PrintComments* |
Use PrintComments to set your preference
on printing the notes that may be attached to cells. Select saxlPrintSheetEnd
to print comments beginning an a separate page at the end of the document.
Select PrintInPlace to print comments where they are displayed when you
view the worksheet. Please note, if you use PrintInPlace, Excel will only
print the comments that are displayed. PrintComments is used when you
want precise control of what and where comments are printed. PrintNotes
simply prints comments in place or does not print comments. Do not use
PrintComments and PrintNotes together.
The PrintComments value names and codes are,
|
saxlPrintInPlace
|
-16
|
|
saxlPrintNoComments
|
0
|
|
saxlPrintSheetEnd
|
-1
|
PrintComments is set to saxlPrintNoComments by default.
Example:
ws.PageSetup.PrintComments= saxlPrintInPlace
Top |
| PrintGridlines* |
Set PrintGridlines to print horizontal
and vertical cell gridlines on worksheets. PrintGridlines is set
to False by default.
Example:
ws.PageSetup.PrintGridlines= True
Top |
| PrintHeadings* |
Set PrintHeadings to print row numbers
and column letters in the A1 reference style or numbered rows and
columns in the R1C1 reference style. PrintHeadings is set to False
by default.
Example:
ws.PageSetup.PrintHeadings= True
Top |
| PrintNotes* |
Use PrintNotes
to print notes that may be attached to cells. Set PrintNotes to true to
print notes where they are displayed when you view the worksheet. (For more
precise control of where notes are printed, please see PrintComments.)
PrintNotes is set to False by default. Do not use PrintNotes and PrintComments
together.
Example:
ws.PageSetup.PrintNotes = True
Top |
| RightFooter* |
Sets or returns a right footer that
will appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.RightFooter = "rightfooter"
Top |
| RightHeader* |
Sets or returns a right header that
will appear on the printed worksheet. For instructions on formatting
headers and footers see,
Formatting Headers and Footers.
Example:
ws.PageSetup.RightHeader = "rightheader"
Top |
| RightMargin* |
Set RightMargin to specify distance
in inches between the worksheet data and the right edge of the
printed page. RightMargin is set to 0 by default.
Example:
ws.PageSetup.RightMargin = 1.25
Top |
| SetPrintTitleColumns* |
Use SetPrintTitleColumns to
set title columns that will be repeated on each page of a printed
worksheet. SetPrintTitleColumns takes two optional parameters:
FirstColumn |
Default Value: 1 |
NumColumns |
Default Value: 1 |
The following sets a title column at column B.
PageSetup.SetPrintTitleColumns 2,1
See also, SetPrintTitleRows
and GetPrintTitles.
Top |
| SetPrintTitleRows* |
Use SetPrintTitleRows to set
title rows that will be repeated on each page of a printed worksheet.
SetPrintTitleRows takes two optional parameters:
FirstRow |
Default Value: 1 |
NumRows |
Default Value: 1 |
The following sets a title row at row 3.
PageSetup.SetPrintTitleRows 3,1
See also, SetPrintTitleColumns
and GetPrintTitles.
Top |
| TopMargin* |
Set TopMargin to specify distance in
inches between the worksheet data and the top edge of the printed
page. TopMargin is set to 0 by default.
Example:
ws.PageSetup.TopMargin = 1.25
Top |
| UseZoom* |
Returns True if Zoom
is enabled, and False if Zoom is disabled. If Zoom is disabled,
FitToPagesWide and FitToPagesTall
are enabled.
Example:
If PageSetup.UseZoom Then
PageSetup.Zoom = 150
Else
PageSetup.FitToPagesWide = 2
PageSetup.FitToPagesTall = 2
End If
Top |
| Zoom* |
Adjusts the size of the printed worksheet
by a specified percentage. The printed worksheet can be enlarged
up to 400%, and reduced to 10%. To enable Zoom, set it to True,
and assign a percentage value to it. Zoom is set to 100 by default.
Note: Zoom and the pair of properties FitToPagesWide
and FitToPagesTall are mutually
exclusive.
Example: The following enlarges the printed worksheet
to 150% of its normal size.
ws.PageSetup.Zoom = True
ws.PageSetup.Zoom = 150
See also, UseZoom.Top |
| *This feature is not available in
ExcelWriterSE, ExcelWriterLE, or ExcelWriterFree. |