Udostępnij za pośrednictwem


WorksheetBase.Previous Property

Definition

Gets a Worksheet that represents the previous sheet.

public:
 property System::Object ^ Previous { System::Object ^ get(); };
public object Previous { get; }
member this.Previous : obj
Public ReadOnly Property Previous As Object

Property Value

A Worksheet that represents the previous sheet; null if the current worksheet is the first sheet in the workbook.

Examples

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.");
    }
}
Private Sub DisplayPrevious()
    If Not (Me.Previous Is Nothing) Then
        Dim sheet As Excel.Worksheet = _
            CType(Me.Previous, Excel.Worksheet)
        MsgBox("The previous worksheet is " & sheet.Name)
    Else
        MsgBox("The current worksheet is the first worksheet.")
    End If
End Sub

Applies to