Class PageSetup (Excel VBA)

The class PageSetup represents the page setup description.

Themes

The following procedures in this class have been grouped together and are described on a separate theme page

Print with its procedures DifferentFirstPageHeaderFooter, EvenPage, FirstPage, FirstPageNumber, FitToPagesTall, FitToPagesWide, OddAndEvenPagesHeaderFooter, Pages, PrintArea, PrintComments, PrintErrors, PrintGridlines, PrintHeadings, PrintNotes, PrintQuality, PrintTitleColumns and PrintTitleRows

Properties

AlignMarginsHeaderFooter returns True for Excel to align the header and the footer with the margins set in the page setup options.

BlackAndWhite true if elements of the document will be printed in black and white.

Worksheets("Sheet1").PageSetup.BlackAndWhite = True

BottomMargin returns or sets the size of the bottom margin, in points.

Worksheets("Sheet1").PageSetup.BottomMargin = _ 
 Application.InchesToPoints(0.5) 
 
Worksheets("Sheet1").PageSetup.BottomMargin = 36

CenterFooter center aligns the footer information in the PageSetup object.

CenterFooterPicture returns a Graphic object that represents the picture for the center section of the footer. Used to set attributes about the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.CentertFooterPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the center footer. 
 ActiveSheet.PageSetup.CenterFooter = "&G" 
 
End Sub

CenterHeader center aligns the header information in the PageSetup object.

CenterHeaderPicture returns a Graphic object that represents the picture for the center section of the header. Used to set attributes about the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.CentertHeaderPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the center header. 
 ActiveSheet.PageSetup.CenterHeader = "&G" 
 
End Sub

CenterHorizontally true if the sheet is centered horizontally on the page when it's printed.

Worksheets("Sheet1").PageSetup.CenterHorizontally = True

CenterVertically true if the sheet is centered vertically on the page when it's printed.

Worksheets("Sheet1").PageSetup.CenterVertically = True

Draft true if the sheet will be printed without graphics.

Worksheets("Sheet1").PageSetup.Draft = True

FooterMargin returns or sets the distance from the bottom of the page to the footer, in points.

Worksheets("Sheet1").PageSetup.FooterMargin = _ 
 Application.InchesToPoints(0.5)

HeaderMargin returns or sets the distance from the top of the page to the header, in points.

Worksheets("Sheet1").PageSetup.HeaderMargin = _ 
 Application.InchesToPoints(0.5)

LeftFooter returns or sets the alignment of text on the left footer of a workbook or section.

LeftFooterPicture returns a Graphic object that represents the picture for the left section of the footer. Used to set attributes about the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.LeftFooterPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the left footer. 
 ActiveSheet.PageSetup.LeftFooter = "&G" 
 
End Sub

LeftHeader returns or sets the alignment of text on the left header of a workbook or section.

LeftHeaderPicture returns a Graphic object that represents the picture for the left section of the header. Used to set attributes about the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.LeftHeaderPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the left header. 
 ActiveSheet.PageSetup.LeftHeader = "&G" 
 
End Sub

LeftMargin returns or sets the size of the left margin, in points.

Worksheets("Sheet1").PageSetup.LeftMargin = _ 
 Application.InchesToPoints(1.5)

Order returns or sets an XlOrder value that represents the order that Microsoft Excel uses to number pages when printing a large worksheet.

Worksheets("Sheet1").PageSetup.Order = xlOverThenDown

Orientation returns or sets an XlPageOrientation value that represents the portrait or landscape printing mode.

Worksheets("Sheet1").PageSetup.Orientation = xlLandscape

PaperSize returns or sets the size of the paper.

Worksheets("Sheet1").PageSetup.PaperSize = xlPaperLegal

Parent returns the parent object for the specified object. Read-only.

RightFooter returns or sets the distance (in points) between the right edge of the page and the right boundary of the footer.

RightFooterPicture returns a Graphic object that represents the picture for the right section of the footer. Used to set attributes of the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.RightFooterPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the right footer. 
 ActiveSheet.PageSetup.RightFooter = "&G" 
 
End Sub

RightHeader returns or sets the right part of the header.

Worksheets("Sheet1").PageSetup.RightHeader = "&F"

RightHeaderPicture returns a Graphic object that represents the picture for the right section of the header. Used to set attributes about the picture.

Sub InsertPicture() 
 
 With ActiveSheet.PageSetup.RightHeaderPicture 
 .FileName = "C:\Sample.jpg" 
 .Height = 275.25 
 .Width = 463.5 
 .Brightness = 0.36 
 .ColorType = msoPictureGrayscale 
 .Contrast = 0.39 
 .CropBottom = -14.4 
 .CropLeft = -28.8 
 .CropRight = -14.4 
 .CropTop = 21.6 
 End With 
 
 ' Enable the image to show up in the right header. 
 ActiveSheet.PageSetup.RightHeader = "&G" 
 
End Sub

RightMargin returns or sets the size of the right margin, in points.

Worksheets("Sheet1").PageSetup.RightMargin = _ 
 Application.InchesToPoints(1.5)

ScaleWithDocHeaderFooter returns or sets if the header and footer should be scaled with the document when the size of the document changes.

TopMargin returns or sets the size of the top margin, in points.

Worksheets("Sheet1").PageSetup.TopMargin = _ 
 Application.InchesToPoints(0.5) 
 
Worksheets("Sheet1").PageSetup.TopMargin = 36

Zoom returns or sets a value that represents a percentage (between 10 and 400 percent) by which Microsoft Excel will scale the worksheet for printing.

Worksheets("Sheet1").PageSetup.Zoom = 150