Worksheet.ListObjects Property (2007 System)

Gets a collection of ListObject objects in the worksheet.

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 ListObjects As ListObjects
'Usage
Dim instance As Worksheet 
Dim value As ListObjects 

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

Property Value

Type: ListObjects
The ListObjects collection for the worksheet.

Examples

The following code example uses the ListObjects property to add a ListObject to the current worksheet.

This example is for a document-level customization.

Private Sub AddListObject()
    Dim range1 As Excel.Range = Me.Range("A1", "A10")
    range1.Formula = "=rand()" 

    Dim listObject1 As Excel.ListObject = _
        Me.ListObjects.Add(Excel.XlListObjectSourceType.xlSrcRange, _
        range1, False, Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo)

    MsgBox("The list object covers the range " & _
        listObject1.DataBodyRange.Cells.Address( _
            ReferenceStyle:=Excel.XlReferenceStyle.xlA1))
End Sub
private void AddListObject()
{
    Excel.Range range1 = this.Range["A1", "A10"];
    range1.Formula = "=rand()";

    Excel.ListObject listObject1 = this.ListObjects.Add(
        Excel.XlListObjectSourceType.xlSrcRange, range1, false,
        Microsoft.Office.Interop.Excel.XlYesNoGuess.xlNo, missing);

    MessageBox.Show("The list object covers the range " +
        listObject1.DataBodyRange.Cells.get_Address(missing, missing,
        Excel.XlReferenceStyle.xlA1, missing, missing));
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace