Worksheet.PageSetup Property (2007 System)

Gets a PageSetup that contains all the page setup settings for the worksheet.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property PageSetup As PageSetup
'Usage
Dim instance As Worksheet 
Dim value As PageSetup 

value = instance.PageSetup
[BrowsableAttribute(false)]
public PageSetup PageSetup { get; }
[BrowsableAttribute(false)]
public:
property PageSetup^ PageSetup {
    PageSetup^ get ();
}
public function get PageSetup () : PageSetup

Property Value

Type: PageSetup
A PageSetup that contains all the page setup settings for the worksheet.

Examples

The following code example uses the PageSetup property to set the bottom and header margins, the first page number, and the center headers and footers of the worksheet.

This example is for a document-level customization.

Private Sub AdjustPageFormat()
    With Me.PageSetup
        .BottomMargin = 10
        .FirstPageNumber = 1
        .HeaderMargin = 10
        .CenterHeader = "December Sales Forcasts"
        .CenterFooter = DateTime.Now.ToShortDateString()
    End With 

    ' Enter a range value and then preview the worksheet to  
    ' display the page setup changes. 
    Me.Range("A1", "A5").Value2 = "Sales" 
    Me.PrintPreview(False)
End Sub
private void AdjustPageFormat()
{
    this.PageSetup.BottomMargin = 10;
    this.PageSetup.FirstPageNumber = 1;
    this.PageSetup.HeaderMargin = 10;
    this.PageSetup.CenterHeader = "December Sales Forcasts";
    this.PageSetup.CenterFooter = DateTime.Now.ToShortDateString();

    // Enter a range value and then preview the worksheet to  
    // display the page setup changes. 
    this.Range["A1", "A5"].Value2 = "Sales";
    this.PrintPreview(false);
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace