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
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
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.