NamedRange.Value2 Property (2007 System)
Gets or 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
<TypeConverterAttribute(GetType(StringConverter))> _
<BindableAttribute(True)> _
Public Property Value2 As Object
'Usage
Dim instance As NamedRange
Dim value As Object
value = instance.Value2
instance.Value2 = value
[TypeConverterAttribute(typeof(StringConverter))]
[BindableAttribute(true)]
public Object Value2 { get; set; }
[TypeConverterAttribute(typeof(StringConverter))]
[BindableAttribute(true)]
public:
property Object^ Value2 {
Object^ get ();
void set (Object^ value);
}
public function get Value2 () : Object
public function set Value2 (value : Object)
Property Value
Type: System.Object
The value of the NamedRange control.
Remarks
The only difference between this property and the Value property is that Value2 is not a parameterized property.
Examples
The following code example uses the Value2 property to set the value of a NamedRange to a value obtained from the AutoComplete method.
This example is for a document-level customization.
Private Sub FindMarthaInTheRange()
Me.Range("A1").Value2 = "Martha lives on a vineyard"
Dim namedRange1 As Microsoft.Office.Tools.Excel.NamedRange _
= Me.Controls.AddNamedRange(Me.Range("A2"), _
"namedRange1")
namedRange1.AddComment("This is Martha's range.")
namedRange1.Value2 = namedRange1.AutoComplete("Ma")
If MessageBox.Show("Clear the range?", "Test", _
MessageBoxButtons.YesNo) = DialogResult.Yes Then
namedRange1.Clear()
End If
End Sub
private void FindMarthaInTheRange()
{
this.Range["A1", missing].Value2 = "Martha lives on a vineyard";
Microsoft.Office.Tools.Excel.NamedRange namedRange1 =
this.Controls.AddNamedRange(this.Range["A2", missing],
"namedRange1");
namedRange1.AddComment("This is Martha's range.");
namedRange1.Value2 = namedRange1.AutoComplete("Ma");
if (MessageBox.Show("Clear the range?", "Test",
MessageBoxButtons.YesNo) == DialogResult.Yes)
{
namedRange1.Clear();
}
}
.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.