Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ApplyNames Method
Collapse the table of content
Expand the table of content

NamedRange.ApplyNames Method

Applies names to the cells in the NamedRange control.

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

Object ApplyNames(
	Object Names,
	Object IgnoreRelativeAbsolute,
	Object UseRowColumnNames,
	Object OmitColumn,
	Object OmitRow,
	XlApplyNamesOrder Order,
	Object AppendLast
)

Parameters

Names
Type: System.Object

An array of the names to be applied. If this argument is omitted, all names on the sheet are applied to the range.

IgnoreRelativeAbsolute
Type: System.Object

true to replace references with names, regardless of the reference types of either the names or references; false to replace absolute references only with absolute names, relative references only with relative names, and mixed references only with mixed names. The default value is true.

UseRowColumnNames
Type: System.Object

true to use the names of row and column ranges that contain the specified range if names for the range cannot be found; false to ignore the OmitColumn and OmitRow arguments. The default value is true.

OmitColumn
Type: System.Object

true to replace the entire reference with the row-oriented name. The column-oriented name can be omitted only if the referenced cell is in the same column as the formula and is within a row-oriented named range. The default value is true.

OmitRow
Type: System.Object

true to replace the entire reference with the column-oriented name. The row-oriented name can be omitted only if the referenced cell is in the same row as the formula and is within a column-oriented named range. The default value is true.

Order
Type: Microsoft.Office.Interop.Excel.XlApplyNamesOrder

Determines which range name is listed first when a cell reference is replaced by a row-oriented and column-oriented range name.

Can be one of these XlApplyNamesOrder constants:

xlColumnThenRow

xlRowThenColumn

AppendLast
Type: System.Object

true to replace the definitions of the names in Names and also replace the definitions of the last names that were defined; false to replace the definitions of the names in Names only. The default value is false.

Return Value

Type: System.Object

You can use the Array function to create the list of names for the Names argument.

If you want to apply names to the entire sheet, use Cells.ApplyNames.

You cannot "unapply" names; to delete names, use the Delete method.

Optional Parameters

For information on optional parameters, see Optional Parameters in Office Solutions.

The following code example uses the ApplyNames method to apply a set of names to a NamedRange control.

This example is for a document-level customization.

private void AddNames()
{
    Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
        this.Controls.AddNamedRange(this.Range["A1", "A5"],
        "namedRange1");

    string[] s = new string[] { "One", "Two", "Three", "Four", "Five" };
    namedRange1.ApplyNames(s, true, true, true, true,
        Excel.XlApplyNamesOrder.xlColumnThenRow, false);
}

Show:
© 2015 Microsoft