NamedRange.set_Value Method (Object, Object)

 

Sets the value of the NamedRange control.

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

void set_Value(
	object rangeValueDataType,
	object arg1
)

Parameters

rangeValueDataType
Type: System.Object

One of the XlRangeValueDataType values that specifies the data type of the range value. The default is xlRangeValueDefault. This parameter is optional in Visual Basic.

_arg1

The value of the NamedRange control. This parameter is optional in Visual Basic.

If you do not need to specify the optional parameters, you can use the Value property instead of this method.

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

The following code example demonstrates how to use the set_Value method.

This version is for a document-level customization.

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

    Microsoft.Office.Tools.Excel.NamedRange namedRange2 =
        this.Controls.AddNamedRange(this.Range["A2"],
        "namedRange2");
    namedRange2.set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault,
        "Jones");
}

This version is for an application-level add-in.

Return to top
Show: