NamedRange.set_Value Method (2007 System)
Sets the value of the NamedRange control.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
Public Sub set_Value ( _
RangeValueDataType As Object, _
_arg1 As Object _
)
'Usage
Dim instance As NamedRange
Dim RangeValueDataType As Object
Dim _arg1 As Object
instance.set_Value(RangeValueDataType, _
_arg1)
public void set_Value(
Object RangeValueDataType,
Object _arg1
)
public:
void set_Value(
Object^ RangeValueDataType,
Object^ _arg1
)
public function set_Value(
RangeValueDataType : Object,
_arg1 : Object
)
Parameters
RangeValueDataType
Type: System.ObjectOne 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.ObjectThe value of the NamedRange control. This parameter is optional in Visual Basic.
Remarks
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 The Variable missing and Optional Parameters in Office Solutions.
Examples
The following code example demonstrates how to use the set_Value method.
This version is for a document-level customization.
Private Sub SetValue()
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A1"), _
"namedRange1")
namedRange1.Value = "Smith"
Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A2"), _
"namedRange2")
namedRange2.set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, _
"Jones")
End Sub
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 Sub SetValue()
Dim vstoWorksheet As Worksheet = CType( _
Me.Application.ActiveWorkbook.Worksheets(1), _
Excel.Worksheet).GetVstoObject()
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= vstoWorksheet.Controls.AddNamedRange(vstoWorksheet.Range("A1"), _
"namedRange1")
namedRange1.Value = "Smith"
Dim namedRange2 As Microsoft.Office.Tools.Excel.NamedRange _
= vstoWorksheet.Controls.AddNamedRange(vstoWorksheet.Range("A2"), _
"namedRange2")
namedRange2.set_Value(Excel.XlRangeValueDataType.xlRangeValueDefault, _
"Jones")
End Sub
private void SetValue()
{
Worksheet vstoWorksheet = ((Excel.Worksheet)
this.Application.ActiveWorkbook.Worksheets[1]).GetVstoObject();
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");
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.