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)

Syntax

'Declaration
Public ReadOnly Property Next As Object
    Get
public Object Next { get; }

Property Value

Type: System.Object
A Microsoft.Office.Interop.Excel.Worksheet that represents the next sheet; nulla null reference (Nothing in Visual Basic) if the current worksheet is the last sheet in the workbook.

Examples

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 Sub DisplayNextWorksheet()
    If Not (Me.Next Is Nothing) Then
        Dim nextSheet As Excel.Worksheet = _
            CType(Me.Next, Excel.Worksheet)
        MsgBox("The next worksheet is " & nextSheet.Name)
    Else
        MsgBox("This worksheet is the last worksheet.")
    End If
End Sub
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.");
    }
}

.NET Framework Security

See Also

Reference

WorksheetBase Class

Microsoft.Office.Tools.Excel Namespace