Expand Minimize

NamedRange.set_Value Method

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
Type: System.Object

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

Optional Parameters

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", missing],
        "namedRange1");
    namedRange1.Value = "Smith";

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


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


private void SetValue()
{
    Worksheet vstoWorksheet =
        Globals.Factory.GetVstoObject(this.Application.ActiveWorkbook.Worksheets[1]);
    NamedRange namedRange1 =
        vstoWorksheet.Controls.AddNamedRange(
        vstoWorksheet.Range["A1", missing],
        "namedRange1");
    namedRange1.Value = "Smith";

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


Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft