WorkbookBase.Sheets Property

Gets a Sheets collection that represents all the sheets in the workbook.

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

Property Value

Type: Sheets
A Sheets collection that represents all the sheets in the workbook.

Remarks

The collection includes worksheets, charts, dialog sheets and macro sheets in the workbook.

Examples

The following code example uses the Sheets property to display the number of sheets in the workbook.

This example is for a document-level customization.

Private Sub DisplayNumberOfSheets()
    MsgBox("There are " & Me.Sheets.Count & _
        " sheets in this workbook.")
End Sub
private void DisplayNumberOfSheets()
{
    MessageBox.Show("There are " + this.Sheets.Count +
        " sheets in this workbook.");
}

.NET Framework Security

See Also

Reference

WorkbookBase Class

Microsoft.Office.Tools.Excel Namespace