Udostępnij za pośrednictwem


Workbook.Worksheets Property (2007 System)

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

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 Worksheets As Sheets
'Usage
Dim instance As Workbook 
Dim value As Sheets 

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

Property Value

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

Remarks

This property does not return macro sheets, charts, or dialog sheets. Use the Sheets property to return those sheets as well as worksheets. You can also use the specialized properties Excel4MacroSheets and Excel4IntlMacroSheets to return macro sheets and the Charts property to return charts.

Examples

The following code example uses the Worksheets property to make the second worksheet in the current workbook invisible.

This example is for a document-level customization.

Private Sub HideSecondWorksheet()
    Dim worksheet As Excel.Worksheet = _
        CType(Me.Worksheets(2), Excel.Worksheet)
    worksheet.Visible = Excel.XlSheetVisibility.xlSheetHidden
End Sub
private void HideSecondWorksheet()
{
    Excel.Worksheet worksheet = (Excel.Worksheet)this.Worksheets[2];
    worksheet.Visible = Excel.XlSheetVisibility.xlSheetHidden;
}

.NET Framework Security

See Also

Reference

Workbook Class

Workbook Members

Microsoft.Office.Tools.Excel Namespace