Compartir a través de


WorksheetBase.Names Property

Definition

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

public:
 property Microsoft::Office::Interop::Excel::Names ^ Names { Microsoft::Office::Interop::Excel::Names ^ get(); };
public Microsoft.Office.Interop.Excel.Names Names { get; }
member this.Names : Microsoft.Office.Interop.Excel.Names
Public ReadOnly Property Names As Names

Property Value

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 void AddName()
{
    Excel.Name name1 = this.Names.Add("Microsoft",
        this.Range["A1"], true, "Ctrl-R");

    // Show Define Name dialog to verify that the Name was added.
    this.Application.Dialogs[Excel.XlBuiltInDialog.xlDialogDefineName].Show();
}
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

Applies to