Worksheet.Previous Property (2007 System)

Gets a Worksheet that represents the previous sheet.

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

Syntax

'Declaration
<BrowsableAttribute(False)> _
Public ReadOnly Property Previous As Object
'Usage
Dim instance As Worksheet 
Dim value As Object 

value = instance.Previous
[BrowsableAttribute(false)]
public Object Previous { get; }
[BrowsableAttribute(false)]
public:
property Object^ Previous {
    Object^ get ();
}
public function get Previous () : Object

Property Value

Type: System.Object
A Worksheet that represents the previous sheet; nulla null reference (Nothing in Visual Basic) 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 Worksheet is the first sheet in the workbook. If the current Worksheet is not the first sheet, then the name of the previous sheet is displayed.

This example is for a document-level customization.

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
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.");
    }
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace