Udostępnij za pośrednictwem


ListObject.Name Property (2007 System)

Gets or sets the name of the ListObject control.

Namespace:  Microsoft.Office.Tools.Excel
Assembly:  Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)

Syntax

'Declaration
Public Property Name As String
'Usage
Dim instance As ListObject 
Dim value As String 

value = instance.Name

instance.Name = value
public string Name { get; set; }
public:
property String^ Name {
    String^ get ();
    void set (String^ value);
}
public function get Name () : String 
public function set Name (value : String)

Property Value

Type: System.String
The name of the ListObject control.

Remarks

This name is used solely as a unique identifier for the ListObjectsItem(Object) property of the ListObjects collection. This property can only be set through the object model.

By default, each ListObject control name begins with the word "List", followed by a number (no spaces). If an attempt is made to set the Name property to a name already used by another ListObject control, an exception is thrown.

Examples

The following code example creates a ListObject in the current worksheet and then uses the Name property to set the name of the ListObject to "Employees".

This example is for a document-level customization.

Private Sub ListObject_Metadata() 
    Dim List1 As Microsoft.Office.Tools.Excel.ListObject = _
        Me.Controls.AddListObject(Me.Range("A1", "D4"), "Employees")

    List1.Name = "Employees"
    List1.Tag = "Employee data"

    MessageBox.Show("The list name is " + List1.Name.ToString() & _
        " and the tag is " & List1.Tag.ToString() + ".")

End Sub
private void ListObject_Metadata()
{
    Microsoft.Office.Tools.Excel.ListObject list1 =
        this.Controls.AddListObject(this.Range["A1", "D4"], "Employees");

    list1.Name = "Employees";
    list1.Tag = "Employee data";

    MessageBox.Show("The list name is " + list1.Name.ToString() +
        " and the tag is " + list1.Tag.ToString() + ".");
}

.NET Framework Security

See Also

Reference

ListObject Class

ListObject Members

Microsoft.Office.Tools.Excel Namespace