This documentation is archived and is not being maintained.

Names.Add Method 

Defines a new name. Returns a Name object.

Namespace: Microsoft.Office.Interop.Excel
Assembly: Microsoft.Office.Interop.Excel (in microsoft.office.interop.excel.dll)

'Usage
Dim Name As Object
Dim RefersTo As Object
Dim Visible As Object
Dim MacroType As Object
Dim ShortcutKey As Object
Dim Category As Object
Dim NameLocal As Object
Dim RefersToLocal As Object
Dim CategoryLocal As Object
Dim RefersToR1C1 As Object
Dim RefersToR1C1Local As Object
Dim returnValue As Name
Dim names1 As Names
returnValue = names1.Add(Name, RefersTo, Visible, MacroType, ShortcutKey, Category, NameLocal, RefersToLocal, CategoryLocal, RefersToR1C1, RefersToR1C1Local)

Name Add(
	[In, Optional] object Name, 
	[In, Optional] object RefersTo, 
	[In, Optional] object Visible, 
	[In, Optional] object MacroType, 
	[In, Optional] object ShortcutKey, 
	[In, Optional] object Category, 
	[In, Optional] object NameLocal, 
	[In, Optional] object RefersToLocal, 
	[In, Optional] object CategoryLocal, 
	[In, Optional] object RefersToR1C1, 
	[In, Optional] object RefersToR1C1Local
);
public Name Add(
	/*in*/System.Object Name, 
	/*in*/System.Object RefersTo, 
	/*in*/System.Object Visible, 
	/*in*/System.Object MacroType, 
	/*in*/System.Object ShortcutKey, 
	/*in*/System.Object Category, 
	/*in*/System.Object NameLocal, 
	/*in*/System.Object RefersToLocal, 
	/*in*/System.Object CategoryLocal, 
	/*in*/System.Object RefersToR1C1, 
	/*in*/System.Object RefersToR1C1Local
);
function Add(
	 Name : Object, 
	 RefersTo : Object, 
	 Visible : Object, 
	 MacroType : Object, 
	 ShortcutKey : Object, 
	 Category : Object, 
	 NameLocal : Object, 
	 RefersToLocal : Object, 
	 CategoryLocal : Object, 
	 RefersToR1C1 : Object, 
	 RefersToR1C1Local : Object
) : Name;

Parameters

Name

Optional Object. Required if NameLocal isn't specified. The text to use as the name. Names cannot include spaces and cannot look like cell references.

RefersTo

Optional Object. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (using A1-style notation). Note Nothing is returned if the reference does not exist.

Visible

Optional Object. True to define the name normally. False to define the name as a hidden name (that is, it doesn't appear in either the Define Name, Paste Name, or Goto dialog box). The default value is True.

MacroType

Optional Object. The macro type, as shown in the following table.

Value

Meaning

1

User-defined function (Function procedure)

2

Macro (also known as Sub procedure)

3 or omitted

None (that is, the name doesn't refer to a user-defined function or macro)

ShortcutKey

Optional Object. The macro shortcut key. Must be a single letter, such as "z" or "Z". Applies only for command macros.

Category

Optional Object. The category of the macro or function if MacroType is 1 or 2. The category is used in the Function Wizard. Existing categories can be referred to either by number (starting at 1) or by name (in the language of the macro). Microsoft Excel creates a new category if the specified category doesn't already exist.

NameLocal

Optional Object. Required if Name isn't specified. The text to use as the name (in the language of the user). Names cannot include spaces and cannot look like cell references.

RefersToLocal

Optional Object. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the user, using A1-style notation).

CategoryLocal

Optional Object. Required if Category isn't specified. Text identifying the category of a custom function in the language of the user.

RefersToR1C1

Optional Object. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (using R1C1-style notation).

RefersToR1C1Local

Optional Object. Required unless one of the other RefersTo arguments is specified. Describes what the name refers to (in the language of the user, using R1C1-style notation).

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows XP Home Edition, Windows XP Professional, Windows Server 2003, and Windows 2000

Target Platforms

Show: