Sdílet prostřednictvím


WorkbookBase.ActiveSheet Property

Definition

Gets the active sheet (the sheet on top).

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

Property Value

The active sheet (the sheet on top); null if no sheet is active.

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 void DisplayActiveSheetName()
{
    Excel.Worksheet worksheet1 = (Excel.Worksheet)this.ActiveSheet;
    MessageBox.Show("The name of the active sheet is: " +
        worksheet1.Name);
}
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

Remarks

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

Applies to