Export (0) Print
Expand All
Expand Minimize

WorksheetBase.Next Property

Gets a Microsoft.Office.Interop.Excel.Worksheet that represents the next 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 Next { get; }

Property Value

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

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

This example is for a document-level customization.

private void DisplayNextWorksheet()
{
    if (this.Next != null)
    {
        Excel.Worksheet nextSheet = (Excel.Worksheet)this.Next;
        MessageBox.Show("The next worksheet is " + nextSheet.Name);
    }
    else
    {
        MessageBox.Show("This worksheet is the last worksheet.");
    }
}

Show:
© 2014 Microsoft