Expand Minimize

WorksheetBase.Previous Property

Gets a Microsoft.Office.Interop.Excel.Worksheet that represents the previous sheet.

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

public Object Previous { get; }

Property Value

Type: System.Object
A Microsoft.Office.Interop.Excel.Worksheet that represents the previous sheet; null if the current worksheet is the first sheet in the workbook.

The following code example uses the Previous property to determine whether the current WorksheetBase is the first sheet in the workbook. If the current WorksheetBase is not the first sheet, then the name of the previous sheet is displayed.

This example is for a document-level customization.

private void DisplayPrevious()
{
    if (this.Previous != null)
    {
        Excel.Worksheet sheet = (Excel.Worksheet)this.Previous;
        MessageBox.Show("The previous worksheet is " + sheet.Name);
    }
    else
    {
        MessageBox.Show("The current worksheet is the first worksheet.");
    }
}

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft