Partilhar via


WorkbookBase.ActiveSheet Property

Gets the active sheet (the sheet on top).

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 ActiveSheet As Object
public Object ActiveSheet { get; }

Property Value

Type: System.Object
The active sheet (the sheet on top); nulla null reference (Nothing in Visual Basic) if no sheet is active.

Remarks

If the workbook appears in more than one window, this property may be different in different windows.

Examples

The following code example uses the ActiveSheet property to display the name of the active worksheet.

This example is for a document-level customization.

Private Sub DisplayActiveSheetName()
    Dim worksheet1 As Excel.Worksheet = _
        CType(Me.ActiveSheet, Excel.Worksheet)
    MsgBox("The name of the active sheet is: " & _
        worksheet1.Name)
End Sub
private void DisplayActiveSheetName()
{
    Excel.Worksheet worksheet1 = (Excel.Worksheet)this.ActiveSheet;
    MessageBox.Show("The name of the active sheet is: " +
        worksheet1.Name);
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace