Share via


Workbook.ActiveSheet Property (2007 System)

Gets the active sheet (the sheet on top).

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 ActiveSheet As Object
'Usage
Dim instance As Workbook 
Dim value As Object 

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

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

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace