Worksheet.Names Property (2007 System)

Gets a Names collection that represents all the worksheet-specific names (names defined with the "WorksheetName!" prefix).

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

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

Property Value

Type: Names
A Names collection that represents all the worksheet-specific names (names defined with the "WorksheetName!" prefix).

Examples

The following code example uses the Names property to add a name to the worksheet. The example then displays the Define Name dialog to verify that the name was added.

This example is for a document-level customization.

Private Sub AddName()
    Dim name1 As Excel.Name = _
        Me.Names.Add("Microsoft", Me.Range("A1"), _
            True, ShortcutKey:="Ctrl-R")

    ' Show Define Name dialog to verify that the Name was added. 
    Me.Application.Dialogs(Excel.XlBuiltInDialog.xlDialogDefineName).Show()
End Sub
private void AddName()
{
    Excel.Name name1 = this.Names.Add("Microsoft",
        this.Range["A1", missing], true, missing, "Ctrl-R",
        missing, missing, missing, missing, missing, missing);

    // Show Define Name dialog to verify that the Name was added. 
    this.Application.Dialogs[Excel.XlBuiltInDialog.xlDialogDefineName].Show(
        missing, missing, missing, missing, missing, missing, missing, missing,
        missing, missing, missing, missing, missing, missing, missing, missing,
        missing, missing, missing, missing, missing, missing, missing, missing,
        missing, missing, missing, missing, missing, missing);
}

.NET Framework Security

See Also

Reference

Worksheet Class

Worksheet Members

Microsoft.Office.Tools.Excel Namespace