ListObjects Property
Returns the ListObjects collection for the Worksheet object. Read-only.
expression.ListObjects
expression Required. An expression that returns a Worksheet object.
Remarks
You use the ListObjects property to return the ListObjects collection for a specified Worksheet object. Then you iterate through the ListObjects collection to get each ListObject object on that worksheet.
Example
The following example works with each ListObjects object related to a Spreadsheet component (named Spreadsheet1). The code uses the ListObjects property of the second Worksheet object to return the ListObjects collection. It then gets the name of the ListObject object. This name corresponds to the value of the ID attribute of an MapInfo/Map/Entry in the schema map syntax in the XML Spreadsheet file.
The XML fragment where the details appear in the XML Spreadsheet file looks something like the following fragment. In this example, the name of the ListObject object is Cust_MapId
:
<x2:MapInfo xmlns:x2="http://schemas.microsoft.com/office/excel/2003/xml">
<x2:Map x2:ID="Cust_MapId">
<x2:Entry x2:ID="example_id" x2:Type="table">
...
</x2:Entry>
</x2:Map>
</x2:MapInfo>
Dim objLists
Dim objList
Dim strName
Set objLists = Spreadsheet1.Worksheets(2).ListObjects
For Each objList in objLists
' Save the ListObject name to a variable.
strName = objList.Name
' Work with that particular list object here.
Next
This example sets the line weight of the border for the specified ListObject in the Spreadsheet component (named Spreadsheet1).
Dim ssConstants
Set ssConstants = Spreadsheet1.Constants
' Set a variable to the range to add the borders to.
rngList = Spreadsheet1.ActiveSheet.ListObjects(1).Range
' Set whole range border weight.
rngList.Weight = ssConstants.owcLineWeightMedium